XPATH – HTMLAgilityPack

So i scrape a webpage from a local server. But i made an example over at :

http://xpather.com/Z6IWzpbo

Now in the example i use : /table/tr[3]/td[4]/@title

This works great to get the full message that is inside the title-attribute of the TD.

Now when i run that in Powershell in combination with the HTMLAgilityPack, it doesn’t work.

I can get the required data with the following code :

[HtmlAgilityPack.HtmlNodeCollection]$body = $doc.DocumentNode.SelectNodes('/html[1]/body[1]/div[2]/table[1]/tr[3]/td[4]') $body.Attributes.GetValue(3).value 

This works but i was wondering why the @title does not work?

Someone has an idea ?

Cheers

submitted by /u/Snak3d0c
[link] [comments]

Leave a Reply