Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

xmldocument to string

Posted on 2002-04-12
4
Medium Priority
?
5,177 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

730 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