Friday, June 22, 2007

The Microsoft XML Parser

Parse XML data to HTML thru JavaScript:

XML data (xml_note.xml) -
?!-- Edited by Charles Kang
-->
?note>
?First_Name>Charles?/First_Name>
?Last_Name>Kang?/Last_Name>
?Position>Software Engineer?/Position>
?Memo>I Love AJAX!?/Memo>
?/note>

HTML with JavaScript file (myxmljavascript.htm) -
?html>
?body>
?script type="text/vbscript">
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("xml_note.xml")
document.write("?h1>Personal Information?/h1>")
for each x in xmlDoc.documentElement.childNodes
document.write("?b>" & x.nodename & "?/b>")
document.write(": ")
document.write(x.text)
document.write("?br>?br>")
next
?/script>
?/body>
?html>

No comments: