Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping special characters inside XPATH

Tags:

escaping

xpath

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!

like image 590
Deelazee Avatar asked Nov 19 '25 16:11

Deelazee


1 Answers

Found a solution using the local-name property. The following works just fine:
//*[local-name()='element']

like image 122
Deelazee Avatar answered Nov 23 '25 06:11

Deelazee