Prevent unmarshaller JAXB from escaping special characters by default

I have an XML file that contains an element with special characters or escape characters in it. When I cancel this file to a Java object, JAXB automatically eludes these characters. However, I do not want them to be escaped, and the object should be populated with any value present in the XML file. A fragment of my XML file looks something like this:

            <Order>
                  <name>Order One &gt;</name>
                  <price>50</price>
            <Order>

The My JAXB Order class is as follows:

            @XmlAccessorType(XmlAccessType.FIELD)
            @XmlRootElement(name = "Order")
            public class Order{

                 @XmlElement
                 private String name;

                 @XmlElement
                 private String price;

                 //skipping getter and setter for brevity

In unmarshalling mode, the name of the class object of the class of the order is set to "Order one," while I want it to be "Order One, &gt;" because this is a requirement.

CDATA, , XML, , , . SO, '&' . . Unmarshalling XML JAXB

JAXB . , , , , . SO JAXB, . .

+3
1

JAXB. MOXy RI- JAXB XML. , , . SAX StAX, unescaping JAXB, , .

XmlAdapter, escape- unmarshal, .

0

All Articles