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.
 
Back
Top