472,122 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

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 16046
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.