简体   繁体   English

XMLStreamReader跳过没有属性的元素

[英]XMLStreamReader skips element with no attribute

I have an XMLStreamReader and when I go thorough the xml it skips one element and goes to the next. 我有一个XMLStreamReader,当我仔细阅读xml时,它会跳过一个元素,转到下一个元素。 I would like to read everything in order so this for me is very annoying and ruins my parsing. 我想按顺序阅读所有内容,因此这对我来说很烦人,并且破坏了我的解析。

This is the XML: 这是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 我想知道如何阅读标签搜索,并确保其中包含

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. 我的猜测是您正在尝试处理元素的文本内容,并且无意中吞下了搜索元素的start元素事件。 (of course, since you've included no code, that's just a guess). (当然,由于您未包含任何代码,因此只是一个猜测)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM