Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xmldocument to string

Posted on 2002-04-12
4
Medium Priority
?
5,188 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:jrspano
4 Comments
 
LVL 1

Expert Comment

by:soferstam
ID: 6937664
I believe it is .xml property of the DOMDocument.
I don't know net,but the objects are the same.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
var currNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
currNode = xmlDoc.documentElement.childNodes.item(0);
alert(currNode.xml);

You also can use xmlDoc.xml

0
 
LVL 6

Accepted Solution

by:
anthony_glenwright earned 200 total points
ID: 6938481
soferstam: he's talking VB.NET, you're talking VB6.

Use the xmldocument.outerXML property.  It is functionally equivalent to the old mxsml2.DomDocument.xml property.
0
 
LVL 6

Expert Comment

by:esolve
ID: 6938615
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...
0
 
LVL 3

Author Comment

by:jrspano
ID: 6942001
worked great thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question