Need help with XSLT:

mwin

2[H]4U
Joined
Jun 24, 2004
Messages
3,378
I'm trying to learn XSLT, and I'm having very little luck with it. My procedural brain just won't wrap around it. I've got a big XML file, and I'm trying to create an output file that has nothing but the tags between the <pl> and </pl>. Nodes of the <pl> tree is what xml heads would probalby say.

Here's what I've got so far:
Code:
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="pl">
      <xsl:copy-of select="."/>
   </xsl:template>

</xsl:stylesheet>

What I'm getting for output from this, though, is this: I've got all the text in the file, but most of the tags have been stripped out. Between <pl> and </pl> I've got tags and text like I'm supposed to. Why is it outputting everything else?
 
Figured it out:

Code:
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="pl">
      <xsl:copy-of select="."/>
   </xsl:template>

   <xsl:template match="text()" />

</xsl:stylesheet>
 
Back
Top