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 needed to do a replace within the same ant file which is tricky as the regex replace operation would also update my regex pattern itself. The solution was to not match the regex pattern signature for example like so will work:

```
<replaceregexp file="${ant.file}"
    match='(name="staticresource.foldername_previous" value=")[^\[\]]*(")'  
    replace='\1${staticresource.foldername}\2'
    byline="true"
/>

```