Question: My goal is to simply update the "lastmod" node in a simple sitemap xml document:

```
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://www.example.com/</loc>
        <lastmod>2005-01-01</lastmod>
    </url>
</urlset> 

```

I want to do this as part of my deploy ant script so I am using the Ant task [XMLTask](http://www.oopsconsultancy.com/software/xmltask/). Here is my ant target:

```
<target name="update-sitemap" description="update the update date">
    <xmltask source="war/sitemap.xml" dest="war/newsitemap.xml" report="true">
        <replace path="/urlset/url/lastmod/text()" withText="new text"/>
    </xmltask>
</target>

```

Unfortunately, my xpath fails to match anything:

```
[xmltask] TextAction(new text) (/urlset/url/lastmod/text()) failed to match

```

I have also tried the following xpath queries with no luck:

```
//lastmod/text()
/urlset[@*]/url/lastmod/text()
/urlset[@xmlns]/url/lastmod/text()

```

I have however discovered that if I manually remove the namespace attribute from the urlset node in my source file, everything works ok.
Is this a bug in XMLTask or am I doing something wrong?

Answer: 
You need to tell XPath that all nodes have a namespace by prefixing with a colon. The correct expression is:

```
/:urlset/:url/:lastmod/text()

```
I couldn't solve the problem. I'm certain XMLTask has some problem when the attribute is "xmlns" because everything works as expected if I rename it to something else ("xmln" for example).

I've simply resigned to using a slightly uglier regex replacement technique:

```
<replaceregexp byline="true">
    <regexp pattern="      &lt;lastmod&gt;(.*)&lt;/lastmod&gt;"/>
    <substitution expression="      &lt;lastmod&gt;new text&lt;/lastmod&gt;"/>
    <fileset file="war/sitemap.xml" />
</replaceregexp>

```

On the plus side, this doesn't require any third party libs.

**Update**: Solved it now. See my other answer.