XML DOM localName 属性

Attr 对象参考手册 Attr 对象

定义和用法

localName 属性返回属性名称的本地部分。

语法

attrObject.localName


实例

下面的代码片段使用 loadXMLDoc() 把 "books_ns.xml" 载入 xmlDoc 中,并返回 "lang" 属性的本地名称:

实例

xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName('book');
​
for(i=0;i<x.length;i++)
{
 document.write("Prefix: " + x.item(i).attributes[0].prefix);
 document.write("<br>");
 document.write("Local name: " + x.item(i).attributes[0].localName);
 document.write("<br>");
 document.write("Namespace URI: " + x.item(i).attributes[0].namespaceURI); 
 document.write("<br>");
 document.write("Base URI: " + x.item(i).attributes[0].baseURI); 
 document.write("<br>");
 document.write("<br>");
}

尝试一下 »

Attr 对象参考手册 Attr 对象

0 个评论

要回复文章请先登录注册