[英]special characters in xml stax parser file
original xml file:
<root> <article>
<artists><artist role="A&R Staff" id="1">Vance</artist><artists></article>
</root>
當我使用stax解析器讀取文件並將其寫入新文件時,它會創建無效的xml文件,因為新文件中沒有&amp。
下面為我工作:
// 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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.