Solved

xmldocument to string

Posted on 2002-04-12
4
5,163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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