Saving to XML file with XmlDocument

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

When using the following code:
doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", the XML file is saved with the correct information by the indentation is not kept. Any idea why?

Also, the first character of the XML file is "". Any idea why?

Thanks so much.
Mike
 
Mike said:
Hi,

When using the following code:

doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", the XML file is saved
with the correct information by the indentation is not kept. Any idea why?

If you want to save an XmlDocument with indentation, use an instance of
XmlTextWriter with the Formatting property set to Formatting.Indented
Also, the first character of the XML file is "". Any idea why?

The characters you're refering to are the Unicode markers for the text file.
 
Great, thanks!


Hi,

When using the following code:

doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", the XML file is saved
with the correct information by the indentation is not kept. Any idea why?

If you want to save an XmlDocument with indentation, use an instance of
XmlTextWriter with the Formatting property set to Formatting.Indented
Also, the first character of the XML file is "". Any idea why?

The characters you're refering to are the Unicode markers for the text file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top