search/replace an xml variable.

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
nleco
Forum Newbie
Posts: 9
Joined: Mon Oct 11, 2004 4:50 pm

search/replace an xml variable.

Post by nleco »

hello all,
here's my problem. I have a variable that stores a string. such as:
(for the time being, ignore exact syntac, i'm going more on how to do this)

<xsl:variable name="varA">
you have %1 <a href="/somepage.php">email</a>
</xsl:variable>

i want to do a search and replace with it.
when i show this variable, i have the actual number in an xml file. I want to somehow replace "%1" with "the number from xml". i tried using the substring and substring-after/before functions. this worked except it strips out the anchor tags. the template code looks something like :

.....
<xsl:value-of select="substring-before($string, '%')" />
<xsl:value-of select="xml/path/to/number" />
<xsl:with-param name="string" select="substring(substring-after($string, '%'), 2)" />
......

any ideas???
Post Reply