0
之间没有特定的父项我尝试选择所有具有属性名称itemprop
的元素,而且whith具有属性itemtype = http://schema.org/Product
的任何级别父项,但位于具有任何其他属性itemtype
的节点中的元素除外。xpath:元素在最终的
实施例:
<div itemtype = "http://schema.org/Product" >
<div itemtype = "http://schema.org/BreadcrumbList" >
<div itemprop = "name" > A </div>
<div itemprop = "price" > B </div>
<div itemtype = "http://schema.org/ListItem" >
<div itemprop = "description"> C </div>
</div>
</div>
<div itemprop = "name" > D </div>
<div>
<div>
<div itemprop = "price" > E </div>
</div>
</div>
</div>
我只需要d和E元素,但不是A,B,C. 我试图somerhing这样的:
//*[normalize-space(@itemtype) = 'http://schema.org/Product']/descendant::*[not(descendant-or-self::*[@itemtype])][@itemprop]
此字符串不是有效的在所有等我的尝试并未排除A,B和C元素。
这是伟大的元素。你帮了我。非常感谢! –