加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 07:58:01 所属栏目:百科 来源:网络整理
导读:如果我使用以下XPath,我可以搜索包含在特定属性中的String / xs:schema / node()/ descendant :: node()[starts-with(@ my-specific-attribute-name-here,’my-search-string’)] 但是,我想搜索包含* String的ANY属性 示例XML: root element1 a="hello" b=
如果我使用以下XPath,我可以搜索包含在特定属性中的String
/ xs:schema / node()/ descendant :: node()[starts-with(@ my-specific-attribute-name-here,’my-search-string’)]

但是,我想搜索包含* String的ANY属性

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

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

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

在你的样本中:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读