Create an XML fileTag(s): WSH VBScript


set xdoc = CreateObject("MSXML2.DOMDocument")

set html = xdoc.appendChild(xdoc.CreateElement("HOWTOS"))
set list = html.appendChild(xdoc.createElement("TOPIC"))
set item = list.appendChild(xdoc.createElement("TITLE"))
set text = xdoc.createTextNode("Java")
item.appendChild text
set item = list.appendChild(xdoc.createElement("URL"))
set text = _  
   xdoc.createTextNode("http://www.rgagnon/javahowto.htm")
item.appendChild text

set list = html.appendChild(xdoc.createElement("TOPIC"))
set item = list.appendChild(xdoc.createElement("TITLE"))
set text = xdoc.createTextNode("Javascript")
item.appendChild text
set item = list.appendChild(xdoc.createElement("URL"))
set text = _
   xdoc.createTextNode("http://www.rgagnon/javascripthowto.htm")
item.appendChild text

xdoc.save "test.xml"

and the result is

<HOWTOS>
<TOPIC>
<TITLE>Java</TITLE>
<URL>http://www.rgagnon/javahowto.htm</URL>
</TOPIC>
<TOPIC>
<TITLE>Javascript</TITLE>
<URL>http://www.rgagnon/javascripthowto.htm</URL><
/TOPIC>
</HOWTOS>

blog comments powered by Disqus