当前位置: 代码迷 >> Web开发 >> javascript xmldoc.getElementByTagName出错
  详细解决方案

javascript xmldoc.getElementByTagName出错

热度:662   发布时间:2012-02-05 12:07:15.0
javascript xmldoc.getElementByTagName出错 - Web 开发 / 其他
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>



------解决方案--------------------
求散分
  相关解决方案