js操作xml

js操作XML文件的例子


 

var  xmlDoc  =   new  ActiveXObject( " Microsoft.XMLDOM " ); 

xmlDoc.async 
=   false ;

xmlDoc.load(
" Tipsxml/tips.xml " );

var  firstinfo = xmlDoc.documentElement.selectSingleNode( " Class[@name='文章管理'] " ).childNodes;

for ( var  j = 0 ;j < firstinfo.length;j ++ )                                    

{

var  newOption  = window.document.createElement( " OPTION " );

if (firstinfo[j].getAttribute( " name " ) != "" )

newOption.text
= firstinfo[j].getAttribute( " name " );

else

newOption.text
= " 全部子类 " ;

newOption.value
= firstinfo[j].getAttribute( " code " );

drp2.options.add(newOption);

}

你可能感兴趣的:(xml)