12.装载纯XML文本进入parser 下面的代码装载文本字符串进入XML parser : <script language="JavaScript"> var text="<note>" text=text+"<to>Tove</to><from>Jani</from>" text=text+"<heading>Reminder</heading>" text=text+"<body>Don't forget me this weekend!</body>" text=text+"</note>" var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.loadXML(text) // ....... PRocessing the document goes here </script>
13.装载XML进入Parser <html> <body>
<script language="javascript"> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml")
document.write("The first XML element in the file contains: ")
遍历XML节点树: <html> <body> <script language="VBScript"> txt="<h1>Traversing the node tree</h1>" document.write(txt) set xmlDoc=CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") for each x in xmlDoc.documentElement.childNodes document.write("<b>" & x.nodename & "</b>") document.write(": ") document.write(x.text) document.write("<br>") next </script> </body> </html>