Thu. Mar 28th, 2024

I was having a hard time grabbing some text using XPath. The HTML in particular looked like this:

<br /><div>I like twertles</div>
<div>Funky
   <br/></div> <p><code>This is my page: 345</code></p><p><code>
     <br />Last Downloaded: 10/13/2011</code></p>

All I wanted to snag was the date of the last download. As you can see, there is no obvious path to that value. BUT, what I do know is that there is a colon in there someplace. This looked like a job for substring-after. I was able to grab this value with this simple XPath:

substring-after(//div[2]/text()[3],':')

By admin

Leave a Reply