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!

Error Creating simple xml file

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
Hi,
I have a problem writing to an xml file.
The error I get when I open the file is "Document must have top level element." Here's the code I am using.

<CODE>
Set doc = CreateObject("Microsoft.XMLDOM")
doc.async = false
doc.ValidateonParse = False
doc.resolveExternals = False

doc.LoadXml("<?xml version='1.0'?><Root><TEST id=0 type=1>ASP</TEST><TEST id=2 type=2>ASP</TEST></Root>")
doc.save "C:\Windows\test.xml"
set doc = Nothing

</CODE>

Does anybody know what is wrong?

Thank you.
 
Try adding single quotes around your values for id and type such as :

<?xml version='1.0'?>
<Root>
<TEST id='0' type='1'>ASP</TEST>
<TEST id='2' type='2'>ASP</TEST>
</Root>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top