开发者

XSLT to remove elements from xml

开发者 https://www.devze.com 2023-02-06 04:16 出处:网络
I have a following xml. <?xml version=\"1.0\" encoding=\"windows-1252\"?> <Person> <Header>

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>
    </Detail开发者_JAVA百科s>
    <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.


<?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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号