[英]How to select all h tags starting from a certain number (XPath)?
我想选择所有h
标签,例如从标签h3
,即h3
, h4
, h5
...我知道如何仅选择h3
:
//h:h3
Use this: 用这个:
//*[matches(name(), '^h\d')]
if there are namespaces in element name then use: 如果元素名称中有名称空间,则使用:
//*[matches(local-name(), '^h\d')]
Keep it simple and just enumerate them: 保持简单,只列举它们:
//*[self::h:h3 or self::h:h4 or self::h:h5 or self::h:h6]
You can use regex in various ways. 您可以通过多种方式使用正则表达式。 For example...
例如...
For all tags of the form h
number : 对于格式为
h
number的所有标签:
//*[matches(local-name(),'^h\d+$')]
For a limited range of a single digit: 对于个位数的有限范围:
//*[matches(local-name(),'^h[3-6]$')]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.