SelectSingleNode relative to a node

Oct 8, 2010 at 8:32 PM

Hello,

I have a document with a bunch of posts.  I select them all like so:

HtmlNodeCollection posts = doc.DocumentNode.SelectNodes("//div[@class='forum_post']");

 

Then I iterator over them:

foreach (HtmlNode post in posts)

 

So far so good, but then, I want to select a node WITHIN a single post.

string content = post.SelectSingleNode("//div[@class='post_content']").InnerText.Trim();

 

Instead of retrieving the post_content from within the current forum_post, instead I get the first post_content div in the entire document.

 

Please let me know if I am doing something wrong, or this is a bug.

Oct 10, 2010 at 1:24 AM

My fault.  I forgot the dot at the beginning of the xpath.