XSLT for-each, iterating through text and nodes -


i'm still learning xslt, , have question for-each loop.

here's have far xml

<body>here great url<link>http://www.somesite.com</link>some more text</body> 

what i'd if for-each loop iterate through these chunks 1. here great url 2. http://www.somesite.com 3. more text

this might simple, or impossible, if can me out i'd appreciate it!

thanks, michael

you should able following:

<xsl:for-each select=".//text()">   <!-- . have value of each chunk of text. -->   <sometext>     <xsl:value-of select="." />   </sometext> </xsl:for-each> 

or may preferable because allows have single template can invoke multiple different places:

<xsl:apply-templates select=".//text()" mode="processtext" /> <xsl:template match="text()" mode="processtext">   <!-- . have value of each chunk of text. -->   <sometext>     <xsl:value-of select="." />   </sometext> </xsl:for-each> 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -