从以下xml文件中我想删除" centrum"基于一个条件从biilingbatch标记。条件是如果是1921然后我想从XML删除centrum标签。在xml中,在不同的不同Parent标签下有许多centrum标签。我想删除那个父标签是billingbatch的中心标签。 我的xml是:
<calculate>
<calculateAmount>
<currency>978</currency>
<individualAmount>-10000</individualAmount>
<billingType>1</billingType>
<billingPeriodEndDate>20260214</billingPeriodEndDate>
<extMvmtFinInstMode>8</extMvmtFinInstMode>
<billingbatch>
<Account>1921</Account>
<Centrum>LBNG</Centrum>
<Company>LNS</Company>
<TextCode>570</TextCode>
<TextData>952491</TextData>
</billingbatch>
<calculatebillingbatch>
<Account>1921</Account>
<Centrum>LBNG</Centrum>
<Company>LNS</Company>
<TextCode>570</TextCode>
<TextData>952491</TextData>
</calculatebillingbatch>
</calculateAmount>
预期结果是:
<calculate>
<calculateAmount>
<currency>978</currency>
<individualAmount>-10000</individualAmount>
<billingType>1</billingType>
<billingPeriodEndDate>20260214</billingPeriodEndDate>
<extMvmtFinInstMode>8</extMvmtFinInstMode>
<billingbatch>
<Account>1921</Account>
<Company>LNS</Company>
<TextCode>570</TextCode>
<TextData>952491</TextData>
</billingbatch>
<calculatebillingbatch>
<Account>1921</Account>
<Centrum>LBNG</Centrum>
<Company>LNS</Company>
<TextCode>570</TextCode>
<TextData>952491</TextData>
</calculatebillingbatch>
</calculateAmount>
答案 0 :(得分:0)
使用身份转换模板
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*| node()"/>
</xsl:copy>
</xsl:template>
和模板
<xsl:template match="billingbatch[Account = 1921]/Centrum"/>