0
votes

XPath noob question: I have an HTML file that contains

<p class="postinginfo">Updated: <time datetime="2013-11-21T12:39:50-0600">2013-11-21, 12:39PM CST</time></p>

<p class="postinginfo">Posted: <time datetime="2013-11-20T12:39:50-0600">2013-11-20, 12:39PM CST</time></p>

I'm trying to extract the time using C# and HtmlAgilityPack

var htmldocs = doc.DocumentNode.SelectNodes("//*[@class=\"postinginfo\"]Updated:/text()");

This did not work. Reading through the XPath tutorial on w3schools.com it wasn't obvious how the functions should be used. I'd appreciate some guidance from a more experienced XPath user.

1

1 Answers

2
votes

I'd suggest you install firefox+firebug+firepath to test xpath expression.
Try this xpath:

//p[@class='postinginfo' and contains(., 'Updated:')]/time/@datetime