This project is read-only.

Regd. replace() and translate() functions in XPATH

Oct 7, 2009 at 1:12 PM


I have an XML like this:

<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
    <shipTo country="US">
        <name>Alice Smith</name>
        <street>123 Maple Street</street>
        <city>Mill Valley</city>

I need to replace a string with another string. I tried the following XPath expression with replace but it doesn't work and throws me an error.

/purchaseOrder/shipTo[replace(name, 'Alice','James')]/name

Alternatively, I have tried using translate.


but the output I 'm getting is Alice Smith only. Could some one give me a suggestion about how to get characters replaced using xpath. I believe the version of XPath I 'm using is 1.0.