问题
I have some elements with the tag <xxx:element>
inside my xml.
I want to get these using XPath. I've tried a few ways of getting them but so far unsuccessful.
//xxx:element
just doesn't return anything. I'm guessing this is because of the :
characater//#xxx:element#
gives the exception: "A location step was expected following the '/' or '//' token."//'xxx:element'
same exception.
Any suggestions?
Based on choroba's answer I found Xml Namespace breaking my xpath!
回答1:
The xxx:
part is a namespace prefix. It should work in XPath, but depending on the language you are using, you might need to register the namespace before you can use it.
回答2:
Found a solution using the local-name property. The following works just fine:
//*[local-name()='element']
回答3:
In saxon //*:element do the trick to me
来源:https://stackoverflow.com/questions/14457960/escaping-special-characters-inside-xpath