How to avoid avoid linebreaks and spaces for XmlWellFormedWriter

Posted by user302670 on Stack Overflow See other posts from Stack Overflow or by user302670
Published on 2010-03-26T16:20:33Z Indexed on 2010/03/26 16:23 UTC
Read the original article Hit count: 498

Filed under:
|
|

Hi,

i am getting an XmlWriter of the AppendChild() method of a xPathNavigator.

        using (XmlWriter writer = xPathNavigator.AppendChild())
        {
            writer.WriteStartAttribute("name");
            writer.WriteEndElement();
        }

The AppendChild() method returns a instance of XmlWellFormedWriter. I want to avoid linebreaks and spaces in my output xml. But the XmlWriterSettings are readonly and using an wrapper does not help anything. I tried this, but the setting of nether the wrapper nor the writer changes:

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.IndentChars = "";
        settings.NewLineChars = "";

        using (XmlWriter wrapper = xPathNavigator.AppendChild())
        {
            XmlWriter writer = XmlWriter.Create(writer, settings);
            writer.WriteStartAttribute("name");
            writer.WriteEndElement();
        }

Does anybody has an idea what todo?

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about xmlwriter