XML DOM Get all XML after Load

221 views Asked by At

I am using the XML DOM loadXML method.

How can I return the entire XML file to a variable after doing this? I know how to parse the XML; I just want the entire XML file as a single chunk of text assigned to a variable. I've scanned the XML DOM Properties but cannot find anything that does this specific task.

Essentially, I want to be able to set varXML = xml.getContents (of course, getContents isn't a real property).

I'm receiving the XML via the Request method using VBScript; VBScript won't allow setting a variable to Request.

Is my only option parsing it out node by node? Surely there is a way to get the entire XML at once?

1

There are 1 answers

0
Ekkehard.Horner On BEST ANSWER

Use the .xml property of the Msxml2.DOMDocument:

>> Dim objMSXML : Set objMSXML = CreateObject("Msxml2.DOMDocument")
>> objMSXML.loadXml "<a>b</a>"
>> WScript.Echo objMSXML.xml
>>
<a>b</a>