Page 1 of 1

Unable to parse any XML input. Error on line 1: The markup in the document preceding the root element must be well-forme

Posted: Fri Oct 04, 2019 4:50 am
by cameron arnott
I am creating an XML in .net using XmlTextWriter to attach as a file in Dynamics.

When I try to test the file I get the error - Unable to parse any XML input. Error on line 1: The markup in the document preceding the root element must be well-formed.

If I open the file in notepad++ and copy and paste the contents into a new text file and save as a new XML file, the new XML file does not return the error.


Thanks.

Re: Unable to parse any XML input. Error on line 1: The markup in the document preceding the root element must be well-f

Posted: Fri Oct 04, 2019 8:50 am
by Radu
Hi,

This forum is mostly for Oxygen XML Editor related problems and not for generic XML questions.
If I were to guess, possibly the original XML document has some kind of byte-order-mark (BOM) bytes in front of the file content. This does not necessarily mean the XML is not wellformed, just that maybe the XmlTextWriter is not 100% compliant with the XML standard.
If you download Oxygen XML Editor and try to open the XML document, does it report any error after the XML is opened? If not, in the Oxygen Preferences->"Encoding" page you can switch the "UTF-8 BOM handling" to "Don't Write", make a small change in the XML and save. Oxygen should remove the BOM bytes from before the XML content.

Regards,
Radu