gpt4 book ai didi

xml - 用于搜索具有包含特定字符串的任何属性的节点的 Xpath?

转载 作者:数据小太阳 更新时间:2023-10-29 01:40:53 25 4
gpt4 key购买 nike

如果我使用以下 XPath,我可以搜索包含在特定 属性中的字符串/xs:schema/node()/descendant::node()[starts-with(@my-specific-attribute-name-here, 'my-search-string')]

但是,我想搜索任何包含*字符串的属性

最佳答案

示例 XML:

<root>
<element1 a="hello" b="world"/>
<element2 c="world" d="hello"/>
<element3 e="world" f="world"/>
</root>

假设,我们需要选择具有任何包含h 的属性的元素。在此示例中:element1element2。我们可以使用这个 XPath:

//*[@*[starts-with(., 'h')]]

在您的示例中:

/xs:schema/node()/descendant::node()
[@*[starts-with(@my-specific-attribute-name-here, 'my-search-string')]]

关于xml - 用于搜索具有包含特定字符串的任何属性的节点的 Xpath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7405212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com