Re: [xml] xml find and replace



On Mon, Jul 16, 2012 at 6:09 AM, stuart shepherd
<jonny wark googlemail com> wrote:
<xsl:template match="//control[name='DelaySeconds']/numeric/max">
<xsl:element name="{name(.)}">
        <xsl:value-of select="translate(string(.), '110', '5')" />
</xsl:element>
</xsl:template>

I think you could just do

<xsl:template match="//control[name='DelaySeconds']/numeric/max[. =
110]/text()">
  <xsl:text>5</xsl:text>
</xsl:template>

Actually I guess you don't care about the original value so you don't
even need the [. = 110] part.

I've tried using replace instead of translate but I get the error message

xmlXPathCompOpEval: function replace not found
XPath error : Unregistered function

replace is an Exslt function, add xmlns:str="http://exslt.org/strings";
to your root node,
then you can call str:replace.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]