I'm trying to get the text of a whole HTML looking document but I would like to exclude certain nodes from the retrieval.
XML
<body> <p>some text</p> <p>some text <img src="whatever"><alt>alt title</alt></p> <div> <p>some text</p> </div> </body> Expected result
I want everything but the alt element so some text*3 = 29 in this example.
I am doing this operation from a for-each on a collection of file. So right now I just do a string(/body) to get everything in each of my file.
I was thinking of a recursive call:
<xsl:function name="lp:gettext"> <xsl:param name="n" /> <xsl:choose> <xsl:when test="$n/child::node()"> <xsl:value-of select="concat(text(),lp:gettext($n/child::node()))" /> </xsl:when> <xsl:when test="$n/name()='alt'" /> <xsl:otherwise> <xsl:value-of select="text()" /> </xsl:otherwise> </xsl:choose> </xsl:function> But I can't seem to use child:: in a function it seems, or not like I do.
How can I achieve what I want to do?
No comments:
Post a Comment