Question

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?

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top