original xml file:
<root> <article>
<artists><artist role="A&R Staff" id="1">Vance</artist><artists></article>
</root>
When i read the file using stax parser and writing it to the new file it creates which makes the invalid xml file because there is no & in the new file.
Below is working for me :
// This can be any InputStream
InputStream is;
XMLInputFactory factory = XMLInputFactory.newInstance();
// Set this property to handle special HTML characters like & etc.
factory.setProperty(XMLInputFactory.IS_COALESCING, true);
// Now use the factory to get the EventReader from the InputStream
XMLEventReader eventReader = factory.createXMLEventReader(is);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.