The processing instruction target matching “[xX][mM][lL]” is not allowed

┬áThe processing instruction target matching “[xX][mM][lL]” is not allowed

This exception reminds me of quote “Much ado about nothing”.

I experienced this exception while parsing an XML using SAXParser. I searched over the web and found many questions on this and there were several others who experienced the same issue. So thought of putting a solution over here, so that it might help someone if they safe something similar.

Well, the solution is pretty simple. The problem is somewhere with the first line of you XML i.e.

<?xml version=”1.0″ encoding=”utf-8″?

In my case there was a whitespace before the start tag <. I trimmed the XML string and that’s all!

Advertisements