Strip comments from XML documents

Discussion in 'XML' started by CI, Jan 11, 2006.

  1. CI

    CI Guest

    I have to create a new XML document from the exising one, by adding
    some additional tags, etc..

    My question is as follows: how to strip XML comments from the existing
    document?

    The identity tranform below copies all the nodes, including comment
    nodes.


    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="xml" indent="yes"/>

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

    </xsl:stylesheet>

    Thanks in Advance

    Michael
     
    CI, Jan 11, 2006
    #1
    1. Advertising

  2. CI

    CI Guest

    Thanks Soren. It did the trick.

    Michael.
     
    CI, Jan 11, 2006
    #2
    1. Advertising

  3. CI

    Soren Kuula Guest

    CI wrote:
    > I have to create a new XML document from the exising one, by adding
    > some additional tags, etc..
    >
    > My question is as follows: how to strip XML comments from the existing
    > document?
    >
    > The identity tranform below copies all the nodes, including comment
    > nodes.
    >
    >
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    > <xsl:eek:utput method="xml" indent="yes"/>
    >
    > <xsl:template match="node( ) | @*">
    > <xsl:copy>
    > <xsl:apply-templates select="@* | node( )" />
    > </xsl:copy>
    > </xsl:template>


    <xml:template match="comment()"/>

    > </xsl:stylesheet>
    >
    > Thanks in Advance
    >
    > Michael
    >

    Soren
     
    Soren Kuula, Jan 11, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KiwiBrian

    Strip all comments

    KiwiBrian, Jul 22, 2004, in forum: HTML
    Replies:
    6
    Views:
    668
    Toby Inkster
    Jul 23, 2004
  2. Replies:
    19
    Views:
    796
    Esmond Pitt
    Nov 2, 2007
  3. Aquila
    Replies:
    35
    Views:
    454
    Mathieu Bouchard
    Mar 31, 2005
  4. Alexandre Mutel
    Replies:
    16
    Views:
    785
    Alexandre Mutel
    Nov 19, 2009
  5. yelipolok
    Replies:
    4
    Views:
    263
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page