Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to xml, want to save data to xml file

Status
Not open for further replies.

aolb

Programmer
Apr 16, 2002
180
GB
I have never used xml before and need to produce an xml file as output from a system which contains 2 pieces of data, i.e. 2 keys.

I have found an example of asp code that that is kind of maybe what I can use but I cant get it to vork. The error I get is "Microsoft VBScript runtime error '800a01a8' Object required: '[object]'.

<Albums>
<Album ref=&quot;CD720&quot;>
<category>Pop</category>
<title>Come On Over</title>
<artist>Shania Twain</artist>
</Album>
<Album ref=&quot;CD024&quot;>
<category>Country & Western</category>
<title>Red Dirt Girl</title>
<artist>Emmylou Harris</artist>
</Album>
</Albums>

Code (VBScript):
Dim objXMLDoc
Set objXMLDoc = CreateObject(&quot;Microsoft.XMLDOM&quot;)
objXMLDoc.async = False
objXMLDoc.load(&quot;albums.xml&quot;)

Set NewText = objXMLDoc.createTextNode(&quot;Country&quot;)
Set Category = objXMLDoc.documentElement.lastChild.firstChild
Set OldText = Category.firstChild
Category.replaceChild NewText, OldText

objXMLDoc.save(&quot;C:\Temp\newAlbums.xml&quot;)


Does anyone have any ideas? The clock is ticking for me and I just want some code that works.
 
Perhaps it doesn't like your taste in music :) Jim Brown,
Johannesburg,
South Africa.
My time is GMT+2
 
the problem's here:

Set objXMLDoc = CreateObject(&quot;Microsoft.XMLDOM&quot;)

this could be that there is no such object as XMLDOM... do some more research into what the object actually is.


 
Nope, the problem is '&' in the xml file i.e. Country & Western.

Got it working now thanks for the help
 
well that'll teach me to read the post thouroughly :)

doh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top