xpath 中的参数化深度查询 [英] Parametrized depth query in xpath

查看:27
本文介绍了xpath 中的参数化深度查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试选择元素 在它们的后代中至少有 2 个不同深度的相同类型的元素.我发现有可能:

I'm trying to select elements <BBB> who have in their descendants at least 2 more elements of the same type at different depths. I found it possible with:

//BBB//BBB//BBB 

但是如果我想更改查询的深度,我必须写:

but if i want to change the depth of my query I have to write:

//BBB//BBB//BBB//BBB
or
//BBB//BBB  

是否可以使用参数指定查询的深度?

Is it possible specify the depth of my query with a parameter?

推荐答案

使用:

//BBB[ancestor::BBB[$pN]]

其中 $pN 应替换为所需数量的不同深度的 BBB 后代.

Where $pN should be substituted with the desired number of BBB descendants at different depths.

这篇关于xpath 中的参数化深度查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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