How to escape special characters on unmarshal xml in JAXB



I have next xml file



<xml name="Places">
<data>
<row Code="1" Name="#X1.A&B(City)" />
</data>
</xml>


And after I'm executing unmarshal I'm getting exception The reference to entity "B" must end with the ';' delimiter because of ampersand(&) inside Name attribute.



JAXBContext jaxbContext = JAXBContext.newInstance(Root.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
File xml = new File("test2.xml");
Object obj = unmarshaller.unmarshal(xml);


How can I escape those characters?


No comments:

Post a Comment