WOW! I don't smoke crack, I swear. I'm going straight to the eye doctor!
<way embarrased>thanks.</way embarrased>
"Tom Lavedas" <> wrote in message
news:bba1f4a5-e107-4a76-8214-...
On Sep 5, 10:40 am, "James" <no...@nowhere.com> wrote:
> Hi, I'm just looking to save some information to file in xml format using
> vbscipt/wsh. Below is the testing code I started to just learn the basics
> of
> creating the xml structure. The code produces file but all the text nodes
> wind up together under one element instead of in there proper place. What
> am
> I doing wrong here?
>
> ------my test code------------------
> Dim xmldoc
> Set xmldoc = CreateObject("msxml2.domdocument")
>
> xmldoc.async = False
> xmlDoc.appendChild(xmlDoc.createProcessingInstruct ion("xml","version=""1.0"""))
>
> Set oRootElement = xmldoc.createElement("NetworkCardConfigs")
> Set elementAdapter = xmldoc.createElement("Adapter")
> elementAdapter.setAttribute "MAC", "testMAC"
>
> Set elementIP = xmldoc.createElement("IP")
> Set txtNodeIP = xmldoc.createTextNode("test ip info")
> Set elementSM = xmldoc.createElement("SM")
> Set txtNodeSM = xmldoc.createTextNode("test sm info")
> Set elementDG = xmldoc.createElement("DG")
> Set txtNodeDG = xmldoc.createTextNode("test dg info")
>
> xmldoc.appendChild(oRootElement)
> oRootElement.appendChild(elementAdapter)
> elementAdapter.appendChild(elementIP)
> elementIP.appendChild(txtNodeIP)
> elementAdapter.appendChild(elementSM)
> elementIP.appendChild(txtNodeSM)
> elementAdapter.appendChild(elementDG)
> elementIP.appendChild(txtNodeDG)
>
> xmldoc.save("testy.xml")
> -------------------------
> ------ output from my test code - testy.xml contents -----------------
>
> <?xml version="1.0" ?>
> <NetworkCardConfigs>
> <Adapter MAC="testMAC">
> <IP>test ip infotest sm infotest dg info</IP>
> <SM />
> <DG />
> </Adapter>
> </NetworkCardConfigs>
> ---------------------------------------------------
Try changing the element names to match the nodes you really want to
address in these two lines of code ...
elementSM.appendChild(txtNodeSM) ' not elementIP
elementDG.appendChild(txtNodeDG) ' not elementIP
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/