Why do I receive an error when I attempt to read an XML file using the XMLREAD function in MATLAB?

I am attempting to read an XML file using the XMLREAD function as shown in the code snippet below:
out = xmlread('514-001.xml')
However, upon execution I receive the following error:
[Fatal Error] :2:8: The processing instruction target matching "[xX][mM][lL]" is not allowed.
??? Java exception occurred:
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:235)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
.
Error in ==> xmlread at 46
parseResult = p.parse(fileName);

 Accepted Answer

The error message indicates that the XML file you are attempting to read is corrupt. You may have bytes at the beginning of your file that appear to be spaces when you look at your XML file in a text editor, but that are really not spaces. These appear as spaces because they are unprintable characters.
To verify this, please open your file using a HEX editor. This will allow you to view the raw and exact contents of the file.

More Answers (0)

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!