Reputation: 5938
I have just learned xpath and xsl and i have a question.
How can i add e.g. the comment <!-- foo -->
to the beginning of each xml element named foo?
Can i do it using xpath or xslt?
Upvotes: 4
Views: 3472
Reputation: 1920
Yes, there is an XSLT element for that: <xsl:comment>.
For doing what you describe, you can use the following:
<!-- Match foo elements in the XML -->
<xsl:template match="foo">
<xsl:comment>foo</xsl:comment>
<foo>
<xsl:apply-templates />
</foo>
</xsl:template>
Upvotes: 5