Xpath: select node based in a condition (with local-name())

后端 未结 3 1788
刺人心
刺人心 2021-01-31 17:23

The question is quite silly, but I am completely stuck. I want to extract child nodes of a node based on a condition. The XML is as follows:

 
 

        
相关标签:
3条回答
  • 2021-01-31 18:01

    You probably meant

    //*[local-name()='a'][*[local-name()='aCode']='aaa']
    
    0 讨论(0)
  • 2021-01-31 18:02

    This one work:

    //*[local-name()='a'][*[local-name()='acode' and text()='a2']]
    

    and also this one:

    //*[local-name()='a'][aCode[text()='a2']]
    
    0 讨论(0)
  • 2021-01-31 18:11

    Try this

    /a/aCode[text()='aaa']
    

    or

    //*[local-name() = 'aCode' and text() = 'aaa']
    

    You have used // at wrong place.

    0 讨论(0)
提交回复
热议问题