欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

XML DOM getAttributeNode() 方法

定義和用法

getAttributeNode() 方法從當(dāng)前元素中通過名稱獲取屬性節(jié)點。

語法:

elementNode.getAttributeNS(ns,name)
參數(shù) 描述
name 必需。規(guī)定要獲取的屬性節(jié)點。

說明

該方法將返回一個 Attr 節(jié)點,表示指定的屬性和值。請注意,通過從 Node 接口繼承的 attributes 屬性也可以獲取該屬性節(jié)點。

實例

在所有的例子中,我們將使用 XML 文件 books.xml,以及 JavaScript 函數(shù) loadXMLDoc()。

下面的例子從 "books.xml" 中的所有 <book> 元素獲取 "category" 屬性:

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
document.write(attnode.name);
document.write(" = ");
document.write(attnode.value);
document.write("<br />");
}

以上代碼的輸出:

category = COOKING
category = CHILDREN
category = WEB
category = WEB