jrspano
asked on
xmldocument to string
I have a variable dimed as an xmldocument in .net
I want to take the xml in the doc and put it in a string variable. Anyone know how to do this
I want to take the xml in the doc and put it in a string variable. Anyone know how to do this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Objects are not the same in .NET
You will have to use different classes in .NET
this is what it looks like in c-charp:
//c-sharp
//declare instance of xml doc
XmlDocument doc = new XmlDocument();
//load xml into memory
doc.Load("c:\\contacts.xml ");
//get hold of the root node
doc.GetElementsByTagName(" contact");
//convert xml into string variable using the innerxml method
string a = doc.InnerXml.ToString();
//display in console window
Console.WriteLine(a);
'vb
Dim doc As System.Xml.XmlDocument
doc = New System.Xml.XmlDocument()
doc.Load("c:\contacts.xml" )
doc.GetElementsByTagName(" contact")
Dim strXML As String
strXML = doc.InnerXml.ToString()
Console.WriteLine(strXML)
Have fun...
You will have to use different classes in .NET
this is what it looks like in c-charp:
//c-sharp
//declare instance of xml doc
XmlDocument doc = new XmlDocument();
//load xml into memory
doc.Load("c:\\contacts.xml
//get hold of the root node
doc.GetElementsByTagName("
//convert xml into string variable using the innerxml method
string a = doc.InnerXml.ToString();
//display in console window
Console.WriteLine(a);
'vb
Dim doc As System.Xml.XmlDocument
doc = New System.Xml.XmlDocument()
doc.Load("c:\contacts.xml"
doc.GetElementsByTagName("
Dim strXML As String
strXML = doc.InnerXml.ToString()
Console.WriteLine(strXML)
Have fun...
ASKER
worked great thanks
I don't know net,but the objects are the same.
var xmlDoc = new ActiveXObject("Msxml2.DOMD
var currNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
currNode = xmlDoc.documentElement.chi
alert(currNode.xml);
You also can use xmlDoc.xml