XML DOM nodeType ÊôÐÔ

¶¨ÒåºÍÓ÷¨

nodeType ÊôÐÔ·µ»Ø½ÚµãµÄÀàÐÍ¡£

Óï·¨£º

attrObject.nodeType

ʵÀý

ÔÚËùÓеÄÀý×ÓÖУ¬ÎÒÃǽ«Ê¹Óà XML Îļþ books.xml£¬ÒÔ¼° JavaScript º¯Êý loadXMLDoc()¡£

ÏÂÃæµÄ´úÂëÆ¬¶ÎÏÔʾ category ÊôÐԵĽڵãÃû³Æ¡¢½ÚµãÖµÒÔ¼°½ÚµãÀàÐÍ£º

xmlDoc=loadXMLDoc("/example/xdom/books.xml");
var x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].nodeName);
document.write(" = ");
document.write(x.item(i).attributes[0].nodeValue);
document.write(" (nodetype: ");
document.write(x.item(i).attributes[0].nodeType + ")");
document.write("<br />");
}

ÒÔÉÏ´úÂëµÄÊä³ö£º

category = children (nodetype: 2)
category = cooking (nodetype: 2)
category = web (nodetype: 2)
category = web (nodetype: 2)
VUE