XSLT to remove elements from xml

2019-08-02 01:42发布

I have a following xml.

<?xml version="1.0" encoding="windows-1252"?>
<Person>
    <Header>
        <Header>1</Header>
     </Header>
    <Details Id="2">
        <First>GERRARD</First>
        <Last>STEVE1                   </Last>
    </Details>
    <Details Id="3">
        <First>GERRARD</First>
        <Last>STEVE2                   </Last>
    </Details>
    <Details Id="3">
        <First>GERRARD</First>
        <Last>STEVE3                   </Last>
    </Details>
    <Footer>
        <Footer>liverpool</Footer>
     </Footer>
</Person>

I need to delete the Details element and generate another xml which looks as follows

<?xml version="1.0" encoding="windows-1252"?>
<Person>
    <Header>
        <Header>1</Header>
     </Header>
    <Footer>
        <Footer>liverpool</Footer>
     </Footer>
</Person>

Thanks in advance.

标签: xslt
1条回答
▲ chillily
2楼-- · 2019-08-02 02:31
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="node() | @*">
    <xsl:copy>
        <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="Details"/>

</xsl:stylesheet>
查看更多
登录 后发表回答