How do I write an XPath query to find all nodes containing a specified child where that child doesn't have a specified value

StackOverflow https://stackoverflow.com/questions/17156288

  •  01-06-2022
  •  | 
  •  

문제

I'm looking for an XPath statement to query for all parents that have a specific child where the child's inner text doesn't contain a specified value:

<Project>
  <ItemGroup>
    <Reference Include="NHibernate">
      <HintPath>..\packages\......</HintPath>
    </Reference>
  </ItemGroup>
</Project>

So I want all the reference nodes that have the HintPath child node only where the path specified in the HintPath doesn't start with "..\packages\"

I can already use //x:Reference[x:HintPath] to get the Reference nodes that contain the HintPath node... I just can't figure out the last bit of the chain...

도움이 되었습니까?

해결책

This should work:

//HintPath[not(starts-with(text(),'..\packages\'))]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top