About Java XMLEventReader

Recently I‘m dealing with a source code data mining project, and I have to use XML in it. But something confusing happens to me. So I searched on Google and finally it got clear.

In this project, I use Event Iterator API of Streaming API for XML (StaX) to parse the XML files. I found a wonderful tutorial here. It really helped me a lot, thanks Lars.

But there is one thing the tutorial missed. Since XMLEventReader works as streaming, it cannot get all data from a event by only reading once. For example, when the content of a node (data between a start element and an end element) contains &lt; or &gt; (tagged by SAX, ‘<‘ and ‘>‘ originally), by calling event.asCharacters().getData(), only characters before these two are fetched. If you want to get them all, a loop should be used here.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。