- JScript code
var xmldoc = new ActiveXObject("Microsoft.XMLDOM"); xmldoc.load("/a.xml"); xmldoc.loadXML("<Colleges></Colleges>"); var colleges=xmldoc.getElementByTagName("collegeName"); //上面这句话出的错误
xml文件
- XML code
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Colleges[ <!ELEMENT Colleges (collegeName,collegeID,Majors)> <!ELEMENT collegeName (#PCDATA)> <!ELEMENT collegeID (#PCDATA)> <!ELEMENT Majors (majorName,majorID,classes)> <!ELEMENT majorName (#PCDATA)> <!ELEMENT majorID (#PCDATA)> <!ELEMENT classes (classID)> <!ELEMENT classID (#PCDATA)>]> <Colleges> <collegeName>Computer Science</collegeName> <collegeID>1</collegeID> <Majors> <majorName>Web Science</majorName> <majorID>11</majorID> <classes> <classID>111</classID> </classes> </Majors> </Colleges>
------解决方案--------------------
求散分