I have the following query (XPath 2.0):
//xref[contains(@href,'#') and @class='- topic/xref ' and @type!='step' and @type!='fig' and @type!='substep']
As you can see, I want to find topic/xref elements with a hash in their href attribute. I want to exclude ceratin types of elements. Problem is, the above query does not display elements with @outputclass='expandable'
I had to run a seperate one to identify them:
//xref[contains(@href,'#') and @outputclass='expandable']
Why does the first, longer query, do not display those elements? I also tried contains(@class='- topic/xref ) instead of @class=' - topic/xref ' and it didn't help.
Try below XPath
:
//xref[@class="- topic/xref " and contains(@href, "#") and not(@type=("fig", "substep", "table") or @outputclass="expandable")]
that will return xref
elements with class="- topic/xref "
and #
in href
attribute but doesn't have type
attribute with values "fig", "substep", "table"
or outputclass
attribute with value "expandable"