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 對象