When an XMLDOMDocument saves itself, how can i get it to include the XML Declaration, e.g.:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-16" ?>
<?xml version="1.0" encoding="UCS-2" ?>
<?xml version="1.0" encoding="UCS-4" ?>
<?xml version="1.0" encoding="ISO-10646-UCS-2" ?>
<?xml version="1.0" encoding="UNICODE-1-1-UTF-8" ?>
<?xml version="1.0" encoding="UNICODE-2-0-UTF-16" ?>
<?xml version="1.0" encoding="UNICODE-2-0-UTF-8" ?>
<?xml version="1.0" encoding="US-ASCII" ?>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml version="1.0" encoding="WINDOWS-1250" ?>
The XMLDOMDomcument object is being created in memory (i.e. the xml is not being loaded from some outside source):
{
IXMLDOMDocument2 doc = new DOMDocument60();
//add nodes to the doc
...
doc.Save(saveTarget);
}
Without the xml declaration you only get the body xml, e.g.:
<Customer>
...
</Customer>
rather than the full XML document:
<?xml version="1.0" encoding="US-ASCII" ?>
<Customer>
...
</Customer>
Question 2
How can i control the encoding the XMLDOMDocument will use when it saves to a stream?