XML DOM prefixプロパティ
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
x
試してみる »
Attr オブジェクト その他の拡張