Reputation: 375
I need convert XML to string use Vbscript. First I create MSXML2.DomDocument
object and load XML.
Dim XmlDoc
Set XmlDoc = CreateObject("MSXML2.DomDocument")
XmlDoc.Load(path_to_xml_file)
Then I want convert this XmlDoc
to string with all tags. But have error in this code:
Dim xmltext As String
xmltext = XmlDoc.xml
I know about .text
method, but it return only value without tags.
How to fix it?
Upvotes: 1
Views: 8180
Reputation: 415
If you have no need to parse the XML, why use MSXML2.DomDocument
at all? I would just read the file into a variable without worrying about what it contains. Here's an example:
Dim fs,t,x
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set t=fs.OpenTextFile("path_to_xml_file",1,false)
x=t.ReadAll
t.close
Response.Write("The text in the file is: " & x)
You can read more about ReadAll here.
Upvotes: 2
Reputation: 167471
Are you sure VBScript
supports as
, as used in dim xmltext as String
? Isn't that VB
or VBA
? I don't find any notation of As
in https://msdn.microsoft.com/en-us/library/zexdsyc0%28v=vs.84%29.aspx
In VBScript
simply use
Dim xmltext
xmltext = xmlDoc.xml
Upvotes: 5