Reputation: 683
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:
<a>
<aCode>aaa</aCode>
<aValue>bbb</aValue>
</a>
The expression is obvious: //a[aCode='aaa']
But I can't get how I should change it if it is with namespaces and I've got to use local-name()
. I've tested the following and it gives a parsing error:
/*[local-name()='a'][[local-name()='aCode']='aaa']
Has anyone any idea of what I should do?
Upvotes: 36
Views: 102704
Reputation: 51
This one work:
//*[local-name()='a'][*[local-name()='acode' and text()='a2']]
and also this one:
//*[local-name()='a'][aCode[text()='a2']]
Upvotes: 5
Reputation: 241898
You probably meant
//*[local-name()='a'][*[local-name()='aCode']='aaa']
Upvotes: 59
Reputation: 11182
Try this
/a/aCode[text()='aaa']
or
//*[local-name() = 'aCode' and text() = 'aaa']
You have used //
at wrong place.
Upvotes: 19