XML DOM prefixプロパティ


Attr 对象参考手册Attr オブジェクト

定義と使用方法

prefix プロパティは、属性の名前空間プレフィックスを設定または返します。

構文

attrObject.prefix


例

次のコードスニペットは、loadXMLDoc()「"" を 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>"); }

上記のコードは次のように出力します:

c
x

試してみる »

Attr 对象参考手册Attr オブジェクト その他の拡張