Connecting Tech Pros Worldwide Forums | Help | Site Map

Indent xml

guy
Guest
 
Posts: n/a
#1: Nov 12 '05
Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
to read.

Oleg Tkachenko [MVP]
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Indent xml


guy wrote:
[color=blue]
> Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
> to read.[/color]

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
guy
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Indent xml


On Tue, 11 May 2004 12:34:50 +0200, "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote:
[color=blue]
>guy wrote:
>[color=green]
>> Is there a simple way to indent xml with dotnet? SQL Server returns a long xml string that is hard
>> to read.[/color]
>
>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());[/color]

I will try it. Thank you for your help.
Closed Thread


Similar .NET Framework bytes