Hi There
First of all, thanks for the people who spend time and energy on such projects.
Also, I seem to have a problem with the agilitypack.
1 - I am trying to get all the images from a particular div tag. (images might be embeded in other divs whithin this particular div), my problem is that all the images of the page are returned even the ones located outside the specified tag.
Is there something wrong with my Xpath in there ?
here is my code
string PromoLink = "http://www.myurl"; HtmlWeb webPromo = new HtmlWeb(); webPromo.PreRequest = new HtmlWeb.PreRequestHandler(OnPreRequest); string PromoUrl = PromoLink; HtmlDocument PromoDoc = webPromo.Load(PromoUrl); HtmlNode extractDiv = PromoDoc.DocumentNode.SelectSingleNode("//div[@id='contentWrapper']"); string PromoData = extractDiv.InnerHtml; var images = extractDiv.SelectNodes("//img[@src]"); var nodes = new Dictionary<string, HtmlNode>(); foreach (var value in images) { string s = value.Attributes["src"].Value; if (!nodes.ContainsKey(s)) { nodes.Add(s, value); } }
Thanks a lot
Chris