XPath: How to select elements based on their value?

前端 未结 2 1281
感动是毒
感动是毒 2020-12-04 05:58

I am new to using XPath and this may be a basic question. Kindly bear with me and help me in resolving the issue. I have an XML file like this:



        
2条回答
  •  醉酒成梦
    2020-12-04 06:19

    The condition below:

    //Element[@attribute1="abc" and @attribute2="xyz" and Data]
    

    checks for the existence of the element Data within Element and not for element value Data.

    Instead you can use

    //Element[@attribute1="abc" and @attribute2="xyz" and text()="Data"]
    

提交回复
热议问题