Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 XPath 1.0 想要获取在每个文本节点上应用 XPath 'substring' 函数的文本节点列表
substring(//p/text(), 10)
仅给出一个第一个文本的子字符串,当
//p/text()
给出所有这些,但要设置所有子字符串
编辑:
试过了
//p/substring(text(), 10)
说无效的 XPath 表达式
我怎样才能做到这一点?
提前致谢
如果您想要一组字符串作为 XPath 1.0 表达式的结果,那么您就不走运了,因为在 XPath 1.0 中没有这样的数据类型:唯一可用的集合是节点集合,您只能选择节点已经存在的,你不能创建新的。
对于 XPath 2.0,这是小菜一碟:
//p/text()/substring(., 10)
因此,如果可能的话,请为自己找一个 XPath 2.0 处理器。