Parsing multiple XML fragments with STaX

本小妞迷上赌 提交于 2019-12-06 01:24:07

Nope. The StAX API does not support fragments. A XMLStreamReader is suitable for exactly one XML document. However, your "hack" isn't that bad at all...

The Woodstox StAX implementation does apparently support this: http://woodstox.codehaus.org/3.2.9/javadoc/com/ctc/wstx/api/WstxInputProperties.html#P_INPUT_PARSING_MODE

As it happens we are already using Woodstox in some places, but I didn't think to Google for Woodstox-specific options!

According to XML spec, an XML document must have a single root element, or else it isn't wellformed. So your so called hack isn't a hack at all, it is the best way to fix up the document....

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!