Solved

xmldocument to string

Posted on 2002-04-12
4
5,144 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now