Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XmlDocument.Save() - Automatic indenting?

$
0
0

Hi

I've added a new Xml-node to my XmlDocument:

XmlDocument xml = newXmlDocument();
xml.Load(
"books.xml");
XmlNode fragment = xml.CreateDocumentFragment();
fragment.InnerXml =
"<Book><Title>MyBook</Title></Book>";
xml.DocumentElement.AppendChild(fragment);
xml.Save(
"books.xml");

The problem is that the added node is not correctly indented.
I want the output to be:

<Book>
  <Title>
    MyBook
  </Title>
</Book>

How do I do this?

Kind Regards


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>