original xml file:
<root> <article>
<artists><artist role="A&R Staff" id="1">Vance</artist><artists></article>
</root>
当我使用stax解析器读取文件并将其写入新文件时,它会创建无效的xml文件,因为新文件中没有&amp; amp。
答案 0 :(得分:-2)
以下是我的工作:
// 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);