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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With