XML document can't be read

  • Last Post 06 October 2015
Philip Johns posted this 02 October 2015

I'm using C# to produce an XML file on the ABBYY server and then I read it using the following:

XmlDocument xmlDoc = new XmlDocument();


However this throws an XmlException stating "DTD must be defined before the document root element". This is referring to the HTML code that is at the end of the file...

Oksana Serdyuk posted this 06 October 2015

Philip, please sorry for the delay with response.

Could you please specify why you speak about HTML and not about XML? Possibly you try to load something else? Your code snippet is OK and it allows to load the correct XML without any problems.

Also our developers recommend you to view the following link http://stackoverflow.com/a/1542101/. You can use XDocument instead of XmlDocument. Moreover you can see our code samples where XDocument is used.