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

xml – 使用xpath选择具有一组多个属性/值的元素

发布时间:2020-12-16 01:53:06 所属栏目:百科 来源:网络整理
导读:我有一个XML文档,我需要删除特定的数据 xml文档具有如下结构: – a b select='yes please' c d='text1' e='text11'/ c d='text2' e='text12'/ c d='text3' e='text13'/ c d='text4' e='text14'/ c d='text5' e='text15'/ /b /aa b select='no thanks' c d=
我有一个XML文档,我需要删除特定的数据

xml文档具有如下结构: –

<a>
   <b select='yes please'>
       <c d='text1' e='text11'/>
       <c d='text2' e='text12'/>
       <c d='text3' e='text13'/>
       <c d='text4' e='text14'/>
       <c d='text5' e='text15'/>
   </b>
 </a>
<a>
   <b select='no thanks'>
       <c d='text1' e='text21'/>
       <c d='text3' e='text23'/>
       <c d='text5' e='text25'/>
   </b>
 </a>
<a>
   <b select='yes please'>
       <c d='text1' e='text31'/>
       <c d='text2' e='text32'/>
       <c d='text3' e='text33'/>
       <c d='text4' e='text34'/>
       <c d='text5' e='text35'/>
   </b>
 </a>
<a>
   <b select='no thanks'>
       <c d='text4' e='text41'/>
       <c d='text3' e='text43'/>
       <c d='text5' e='text45'/>
   </b>
 </a>

我需要选择只有那些/ a / b元素组,d属性=’text1’和
d attribute =’text4’,一旦我已经识别这些子文档,我想获得e属性的值,d属性值’text5′

希望明白

干杯

DD

您可以使用此XPath:
//a[b/c/@d = 'text1' and b/c/@d = 'text4']/b/c[@d = 'text5']/@e

它将选择第一和第三个a / b的e =’text15’和e =’text35′

XSLT:

<xsl:template match="//a[b/c/@d = 'text1' and b/c/@d = 'text4']/b/c[@d = 'text5']">
  <xsl:value-of select="@e"/>
</xsl:template>

(编辑:李大同)

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

    推荐文章
      热点阅读