Given the xml:
<div itemtype="..." itemscope value="root">
<div itemprop="..." value="1" /> <!-- want this -->
<div value="2">
<div itemprop="..." value="3" /> <!-- and this -->
</div>
<div itemtype="..." itemscope itemprop="..." value="4"> <!-- and even this -->
<div itemprop value="5" /> <!-- but not this -->
<div value="6" >
<div itemprop value="7" > <!-- nor this -->
</div>
</div>
</div>
I am trying to build an xpath query that returns all descendants of the root, which have an itemprop
attribute, but are not descendants of a "nested" element with the itemscope
attribute. That is, I want all of the the root's properties, but not properties within nested scopes. I'm fairly convinced this cannot be done in XPath 1.0. My naive attempt: /descendant::*[not(@itemscope)]//*[@itemprop]
returns all itemprop
'ed elements that have some ancestor with no itemscope
attribute
No comments:
Post a Comment