Groups | Blog | Home
all groups > dotnet xml > march 2005 >

dotnet xml : Convert an xml document to a string or stringbuilder?


Steve
3/4/2005 12:57:01 PM
Hello. I am relatively new to using XML, but I'm trying to convert an xml
document directly to a string or stringbuilder. I'm trying to use the
XmlDocument class and Stringwriter classes, but I am unsucessful. What am I
missing? Thank you for your help in advance!

--
v-kevy NO[at]SPAM online.microsoft.com
3/5/2005 2:22:29 AM
Hi Steve,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the whole xml document
as a string to a string object. If there is any misunderstanding, please
feel free to let me know.

In this case, we can use XmlDocument.OuterXml to get the whole document as
a string. Here's an example:

XmlDocument doc = new XmlDocument();
doc.Load(@"c:\a.xml");
this.textBox1.Text = doc.OuterXml;

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Steve
3/7/2005 8:43:17 AM
Thanks Kevin. That's what I'm looking for, however, I am using the 2.0
framework. The OuterXML has moved somewhere else. Any ideas where? Thank
you!

[quoted text, click to view]
v-kevy NO[at]SPAM online.microsoft.com
3/8/2005 6:46:55 AM
Hi Steve,

I checked it on my computer, the OuterXml property still exists in
XmlDocument class in .net framework 2.0. Since .NET framework is backward
compatible, I don't think it will be moved to anywhere else. I'm currently
using Visual Studio .NET 2005 beta1.

If anything is unclear, please feel free to reply to this post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
AddThis Social Bookmark Button