By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,707 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,707 IT Pros & Developers. It's quick & easy.

Indent xml

P: n/a
guy
Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
to read.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
guy wrote:
Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
to read.


XmlReader r = new XmlTextReader(new StringReader(myXML));
StringWriter sw = new StringWriter();
XmlTextWriter w = new XmlTextWriter(sw);
w.Formatting = Formatting.Indented;
while (r.Read())
w.WriteNode(r, false);
w.Close();
r.Close();
Console.WriteLine(sw.ToString());
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

P: n/a
guy
On Tue, 11 May 2004 12:34:50 +0200, "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote:
guy wrote:
Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
to read.


XmlReader r = new XmlTextReader(new StringReader(myXML));
StringWriter sw = new StringWriter();
XmlTextWriter w = new XmlTextWriter(sw);
w.Formatting = Formatting.Indented;
while (r.Read())
w.WriteNode(r, false);
w.Close();
r.Close();
Console.WriteLine(sw.ToString());


I will try it. Thank you for your help.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.