The column name contains a space. XML element names cannot contain a space. The space is used in XML to separate element names from attribute names, for example:
<ElementName Attribute1="value" />
The DataTable.WriteXml method tries to write an XML file in a consistent way, so that later it can use another DataTable to load XML and bring it as close as possible to an exact copy of the original. Therefore, it replaces illegal characters with hexadecimal values, so that illegal characters are not lost during translation.
So, if you want to write it in XML in different ways, you need to either:
- Change the column name in the
DataTable so that it does not contain a space - Manually output the XML yourself using
XDocument , XmlDocument , XmlWriter or XmlSerializer and format the output, but you want to - Output the XML as it is now, and then run the XSLT script to fix the formatting
source share