How to troubleshoot 'String could not be parsed as XML' error message in PHP

This article describes how to troubleshoot the "String could not be parsed as XML" error message in PHP.

Tabla de contenido


When you try to parse XML data in a PHP script, you receive the following error message:

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in FILENAME on line X


The most likely cause of this error is that the XML data you are trying to process is not valid. Alternatively, the XML data may contain non-standard characters or use a different character set encoding.

There are several websites that can validate XML data. For example, the website can check basic XML syntax, as well as validate XML data against external schema, such as DTD (Document Type Definition) documents.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.