I want to search documents which do not have particular element or element having no child node(even text node) and the element should have a particular parent node.
for example:
sample xmls:
<root>
<id>123</id>
<root2>
<number>1234</number>
</root2>
</root>
<root>
<id>123</id>
<root2>
<issue/>
<number>1234</number>
</root2>
</root>
<root>
<id>123</id>
<root2>
<volume/>
<number>1234</number>
</root2>
</root>
<root-second>
<id>123</id>
<root2>
<volume/>
<issue/>
<number>1234</number>
</root2>
</root-second>
<root-second>
<id>123</id>
<root2>
<volume/>
<issue/>
<number>1234</number>
</root2>
</root-second>
New Docs:
<root>
<id>123</id>
<root2>
<volume>233</volume>
<number>1234</number>
</root2>
</root>
<root>
<id>123</id>
<root2>
<volume>233</volume>
<issue>233</issue>
<number>1234</number>
</root2>
</root>
<root>
<id>123</id>
<root2>
<issue>233</issue>
<number>1234</number>
</root2>
</root>
Now I want all xmls having <id>
in <root>
is 123 and <root2>
can have empty <issue>, <volume>
element or element(s) not present at all.
As in the above case, it should not return xmls with <root-second>
as root.
It should return all xmls with <root>
as root
Assuming each XML is in its own document, you should be able to do this with:
I'm not entirely clear on your question, but I think you might also be wanting to require that
root2
be present under root, regardless of what it might contain. If that's the case, then: