0

I want to take all "grand" nodes which are inside specific nodes (not all*). In the example bellow, I want all "grand" nodes which are inside "foo", "buz" and "more". Is there a possibility of searching by multiple parents. '//{multiple parent nodes}/grand'???

<doc>
    <foo>
        <grand>Hello</grand>
    </foo>
    <bar>
        <grand>Hello</grand>
    </bar>
    <buz>
        <grand>Hello</grand>
    </buz>
    <other>
        <grand>Hello</grand>
    </other>
    <more>
        <grand>Hello</grand>
    </more>
</doc>

*The nodes I want to search are not by pattern.

Ivo
  • 244
  • 2
  • 12
  • For your specific case, `//*[starts-with(local-name(), 'node')]/grand` should work (although the XML is badly formed as you have `` – Nigel Ren Oct 28 '19 at 08:37
  • Form copy and pasting and editing forgot to replace "word". This is just pseudo xml. I will edit my example, because I mislead you. The names are not by pattern. Can I specified a list of names that I want to search. – Ivo Oct 28 '19 at 09:00
  • 1
    Just added another duplicate for that - which would mean something like `//grand[parent::node-1|parent::node-3]` – Nigel Ren Oct 28 '19 at 09:09
  • @NigelRen Thaks – Ivo Oct 29 '19 at 10:33

0 Answers0