TUTORIALFrontendFETCHED
XML DOM value 属性
XML DOM value 属性 Attr 对象 定义和用法 value 属性返回属性的值。 语法 attrObject.value 实例 下面的代码片段使用 loadXMLDoc() 把 'books.xml' 载入 xmlDoc 中,并显示 category 属性的名称和值: 实例 [mycode3 type='js'] xmlDoc=loadXMLDoc('boo..
Updated 7/16/2026
Tutorial detail pages default to noindex.
XML DOM value 属性
Attr 对象
定义和用法
value 属性返回属性的值。
语法
attrObject.value
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并显示 category 属性的名称和值:
实例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].name);
document.write(" = ");
document.write(x.item(i).attributes[0].value);
document.write("<br>");
}
输出:
category = COOKING
category = CHILDREN
category = WEB
category = WEB
category = CHILDREN
category = WEB
category = WEB
尝试一下 »
Attr 对象