Ken Wilson wrote:
[color=blue]
> I am writing and .xml file and am not getting the formatting I would
> like.[/color]
[color=blue]
> XmlTextWriter tw = new XmlTextWriter(filename);
>
> tw.Formatting = Formatting.Indented;[/color]
[color=blue]
> tw.WriteStartElement("MyString);
> tw.WriteString("This is the string");
> tw.WriteEndElement();[/color]
[color=blue]
> The output I get is formatted as follows.[/color]
[color=blue]
> <MyString>This is the string</MyString>[/color]
[color=blue]
> My questions is how do I get the MyString tags and the string itself
> to each appear on consecutive lines, i.e.
>
> <MyString>
> This is the string
> </MyString>[/color]
There is nothing in the XmlTextWriter implementation that gives you that
formatting, it does not make much sense to have white space added
automatically to text content in an element.
If you want that you will need your own implementation of XmlWriter or
at least extend XmlTextWriter.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/