I want to extract tags in XML which contains attribute condition as name="var". But I don’t know which element has got this attribute condition so can I use following XQuery:
<ab>
<c name="var">
<d name ="var">
<e>
</e>
</d>
<f>
</f>
</c>
</ab>
XQuery:
doc('abc.xml')//ab/*[@name="var"]
I have XML generated by CLANG which has no values for tags but everything is present as attribute only.
You’re currently select all elements in
abc.xmlwhich are children of an element called<ab>and have the given attribute.As you want “extract tags in XML which contains” and the document provided I guess you actually want to query all elements within top-level-element
<ab>, which would be written asand return both element
<c>and<d>with their respective child nodes.