![](/img/trans.png)
[英]xslt rearrange xml nodes (remove some of them) and create new node with name based on attribute value
[英]Remove XML Node based on attribute value with XSLT
我的目標是在StatusDate為1900-01-01T00:00:00時使用此XSLT樣式表刪除整個LoanSecondaryStatus節點,但在其他任何日期時都保留該節點。
我有以下XML:
<Loans>
<Loan>
<LoanSecondaryStatus>
<StatusName>Application Started</StatusName>
<StatusDate>1900-01-01T00:00:00</StatusDate>
</LoanSecondaryStatus>
<LoanSecondaryStatus>
<StatusName>Application Finished</StatusName>
<StatusDate>2016-03-02T00:00:00</StatusDate>
</LoanSecondaryStatus>
</Loan>
</Loans>
這是我用來嘗試刪除LoanSecondaryStatus節點的XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/LoanSecondaryStatus[not(StatusDate='1900-01-01T00:00:00')]"/>
</xsl:stylesheet>
當StatusDate為1900-01-01T00:00:00時,刪除整個LoanSecondaryStatus節點
我相信您的第二個模板必須是:
<xsl:template match="LoanSecondaryStatus[StatusDate='1900-01-01T00:00:00']"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.