truthSeekr truthSeekr - 1 year ago 113
Java Question

Marshalling special characters with Apache XML Beans

I have a schema which I use XmlBeans to umarshall to Java objects. I have no control over the the data that comes through.

One such field looks like

<Name>Barnes & Noble</Name>

Parsing fails at the character
with lexical error. Is there a way to specify an option while parsing XML files to ignore some special characters?

Any help you could provide will be great.

Answer Source

No. This is invalid XML. Ampersand must be escaped into "&amp;".

You can manually escape all ampersand before parsing it as XML but that may mess up other XML entities.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download