在XPATH中转义特殊字符 [英] Escaping special characters inside XPATH

查看:443
本文介绍了在XPATH中转义特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的xml中有一些标签为< xxx:element> 的元素。

I have some elements with the tag <xxx:element> inside my xml.

我想使用XPath来获取它们。我尝试了几种方法来获取它们,但到目前为止没有成功。

I want to get these using XPath. I've tried a few ways of getting them but so far unsuccessful.

// xxx:element 只是不返回任何内容。我猜这是因为 characater

// ##:element#给出了例外:应该在'/'或'//'令牌之后执行定位步骤。

//'xxx:element'

//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.

有任何建议吗?

根据choroba的回答,我发现Xml命名空间破坏了我的xpath!

Based on choroba's answer I found Xml Namespace breaking my xpath!

推荐答案

使用local-name属性找到了解决方案。以下工作正常:

// * [local-name()='element']

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

这篇关于在XPATH中转义特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆