I am using JAXB to convert string xml data to POJO as follows.
JAXBContext jaxbContext = JAXBContext.newInstance(Employee.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(temp);
Employee emp = (Employee) unmarshaller.unmarshal(reader);
It goes fine, but it's always trying to validate text of each element during unmarshal and sometimes got failed. That I don't want, because in text there are lot of html tags and sometimes they are erroneous too.
So, I want JAXB to skip the entire text and pass it as it is to form POJO data. Is there any way to achieve this. Any help will be appreciated.
Here is an example, you need to use @XmlAnyElement to get the content as it is without using
CDATA
.Employee.java:
NameHandler.java:
JAXB:
prints the content as it is:
Hope it helps.