xml xpath:查找具有给定属性的节点,该属性的值包含一个字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/614797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:23:20  来源:igfitidea点击:

xpath: find a node that has a given attribute whose value contains a string

xmlxpathcontains

提问by flybywire

Is there an xpath way to find a node that has a given attribute whose value contains a given string?

是否有 xpath 方法来查找具有给定属性的节点,该属性的值包含给定字符串?

For example I have an xml document and want to find a node where the addressattribute contains the string Downing, so that I could find the following node:

例如,我有一个 xml 文档,想找到一个address属性包含 string的节点Downing,以便我可以找到以下节点:

<person name="blair" address="10 Downing St. London"/>

回答by vartec

select="//*[contains(@address,'Downing')]"