Subject: Replace command?
Posted By: mcw22 Post Date: 8/21/2006 1:17:21 AM
I heard that it's possible to perform a replace command inside XML.

Suppose I have this line of code:

<replace var="$total$" regexp="&lt;font size=-1&gt;Results &lt;b&gt;([0-9]*)&lt;/b&gt; - &lt;b&gt;([0-9]*)&lt;/b&gt; of about &lt;b&gt;([^&lt;]*)&lt;/b&gt; replacement="(([^0-9]*),[]),$3 />

whereby I want to remove the commas for the third parenthesis (think 618,000,000 ----> 618000000)is that the right way or is there a better way to do that function above?

Thanks
Reply By: mhkay Reply Date: 8/21/2006 2:22:13 AM
XML is data, there are no commands in XML, so it's not clear what you mean here. There might be some language that supports a construct like the one you've written here, but if so, I haven't heard of it. Most languages that operate on XML, such as XSLT and XQuery, operate at the level of XML as a tree of nodes, not the lexical level of markup and angle brackets as featured in your sample.

The usual way of removing commas from a number would be the translate() function in XSLT/XPath.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Go to topic 48609

Return to index page 198
Return to index page 197
Return to index page 196
Return to index page 195
Return to index page 194
Return to index page 193
Return to index page 192
Return to index page 191
Return to index page 190
Return to index page 189