I get an error when trying to parse a XML file with escape characters in it using the following java code. Is there a way to handle it while parsing the file here?
private Document parseXmlFile(String fileName) {
Document doc = null;
try {
File fXmlFile = new File(fileName);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
} catch (ParserConfigurationException | SAXException | IOException ex) {
System.out.println(ex);
}
return doc;
}
Sample XML
<ResultDetail>
<ObjectType>APF</ObjectType>
<ObjectName>dlgCreateNewEmployee</ObjectName>
<Header>AccessModifiers Detected</Header>
<Description>&Original source: private</Description>
</ResultDetail>