M
Martin
Hi,
I would like to ask to ask why when I output some xml to the console window
i get different encodings.
for example, consider the following code.
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(@"<?xml version=""1.0"" encoding=""utf-16""?>
<Vehicle xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<VIN>VIN</VIN>
<Make>Make</Make>
<Model>Model</Model>
</Vehicle>");
when i run this in a console window and execute the following line
xmldoc.Save(Console.Out);
i get the following xml - notice that the encoding is "IBM437" and not
"UTF-16" as originally specified
<?xml version="1.0" encoding="IBM437"?>
<Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http:/
/www.w3.org/2001/XMLSchema">
<VIN>VIN</VIN>
<Make>Make</Make>
<Model>Model</Model>
</Vehicle>
however when I used the following line
Console.WriteLine(xmldoc.OuterXml);
The it appears in the console window with the correct formating.
can anybody please explain why this is.
many thanks in advance.
cheers
martin.
I would like to ask to ask why when I output some xml to the console window
i get different encodings.
for example, consider the following code.
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(@"<?xml version=""1.0"" encoding=""utf-16""?>
<Vehicle xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<VIN>VIN</VIN>
<Make>Make</Make>
<Model>Model</Model>
</Vehicle>");
when i run this in a console window and execute the following line
xmldoc.Save(Console.Out);
i get the following xml - notice that the encoding is "IBM437" and not
"UTF-16" as originally specified
<?xml version="1.0" encoding="IBM437"?>
<Vehicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http:/
/www.w3.org/2001/XMLSchema">
<VIN>VIN</VIN>
<Make>Make</Make>
<Model>Model</Model>
</Vehicle>
however when I used the following line
Console.WriteLine(xmldoc.OuterXml);
The it appears in the console window with the correct formating.
can anybody please explain why this is.
many thanks in advance.
cheers
martin.