这段代码什么问题
function parseXML(){ //解析XML文件 var xmlDoc = window.ActiveXObject? new ActiveXObject("Microsoft.XMLDOM"):document.implementation.createDocument("","",null); if(xmlDoc != null){ xmlDoc.async = false; xmlDoc.load("test.xml");//加载XML文件 document.write(xmlDoc.getElementsByTagName("to").length); }else { document.write("error"); } }
<?xml version="1.0" encoding="gb2312"?><!DOCTYPE note SYSTEM "note.dtd"><note id="small" value="2"> <to father="hai"> <firstname>yu</firstname> <familyname>hai</familyname> </to> <to father="haid"> <firstname>yud</firstname> <familyname>haidfd</familyname> </to> <from>yuhai</from> <heading>testing</heading> <body content="1">sdfsd &writer; &version;</body></note>