XMLStreamReader 跳过没有属性的元素
我有一个 XMLStreamReader,当我仔细阅读 xml 时,它会跳过一个元素并转到下一个元素。我想按顺序阅读所有内容,所以这对我来说非常烦人并且破坏了我的解析。
这是 XML:
<bar>Chaps
<drink>
<search>
<containgLetter>ri</containgLetter>
</search>
</drink>
<bar>
这是我得到的标签的顺序
- bar
- Drink
- containsLetter
我想要的是
- bar
- Drink
- 搜索
- containsLetter
我想知道如何读取标签搜索并确保其包含在内
I have an XMLStreamReader and when I go thorough the xml it skips one element and goes to the next. I would like to read everything in order so this for me is very annoying and ruins my parsing.
This is the XML:
<bar>Chaps
<drink>
<search>
<containgLetter>ri</containgLetter>
</search>
</drink>
<bar>
This is the what i get the order of the tags
- bar
- drink
- containingLetter
What I want is
- bar
- drink
- search
- containingLetter
I want to know how to read the tag search and make sure that its included
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,您正在尝试处理元素的文本内容,并且无意中吞下了搜索元素的开始元素事件。 (当然,由于您没有包含任何代码,所以这只是一个猜测)。
My guess would be that you are attempting to process the text content of the elements and are inadvertently swallowing the start element event for the search element. (of course, since you've included no code, that's just a guess).