469,336 Members | 5,278 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Convert an xml document to a string or stringbuilder?

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!

--
Steve
Nov 12 '05 #1
3 15820
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."

Nov 12 '05 #2
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!

"Kevin Yu [MSFT]" wrote:
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."

Nov 12 '05 #3
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."

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alessandro | last post: by
4 posts views Thread by James Geurts | last post: by
6 posts views Thread by centrino | last post: by
5 posts views Thread by Mika M | last post: by
4 posts views Thread by James Page | last post: by
4 posts views Thread by Jonathan Wood | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.