I'm trying to parse xml files provided to me. I'm parsing the files using javax.xml DocumentBuilder. The files can contain tags that have quoted inner xml which I do not want parsed.
Shortened example:
<Property Name="Value" PreFormatted="1">"<?xml version='1.0' encoding='UTF-16'?>"</Property>
When I run the parser as so:
Document document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))));
I receive the following error:
[Fatal Error] :1:106: The processing instruction target matching "[xX][mM][lL]" is not allowed.
I understand that this error occurs when you have more than one xml declaration in the code, but I am unable to figure out how to prevent the parser from attempting to parse the quoted xml.
How can I prevent quoted xml from being parsed?