0
original xml file: 
<root> <article>
<artists><artist role="A&amp;R Staff" id="1">Vance</artist><artists></article>
</root>

当我使用 stax 解析器读取文件并将其写入它创建的新文件时,这会生成无效的 xml 文件,因为新文件中没有 &。

4

1 回答 1

-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);
于 2015-06-22T13:38:00.350 回答