Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, So im trying to get a variable of type double from a book website, this is my current progress:

C#
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
var rootNode = htmlDoc.DocumentNode;
var bookResult = rootNode.SelectNodes("//div[@class='result-detail']");
//var bookLink = allBookResults.InnerText.Trim();
var dataNode = bookResult.SelectSingleNode(".//div[@Class='item-price']");
var bookPriceNode = dataNode.SelectSingleNode(".//span1");
string bookPrice = bookPriceNode.InnerText.Trim();


the first problem is
Error   1   'HtmlAgilityPack.HtmlNodeCollection' does not contain a definition for 'SelectSingleNode' and no extension method 'SelectSingleNode' accepting a first argument of type 'HtmlAgilityPack.HtmlNodeCollection' could be found (are you missing a using directive or an assembly reference?)


and highlights the underlined code.

the second problem is im trying to convert the bookprice to double but then it wont let me use inner text.

how do i select the price content of span property? am I doing it right?
Below is the Div Class of what im trying to extract
HTML
  <div class="result-detail">
<span property="url" content="http://www.abebooks.com/servlet/BookDetailsPL?bi=11698135711"></span>
<div class="item-price" typeof="Offer" property="offers">
    <span property="price" content="41.95"></span>
    <span property="priceCurrency" content="USD"></span>
    <span property="itemCondition" content="UsedCondition"></span>
    <span property="availability" content="InStock"></span>

</div>

Thanks alot. :)
Posted
Updated 26-Dec-13 6:08am
v2
Comments
H.Brydon 26-Dec-13 16:06pm    
I'm not an expert in this area but my guess is that you should be using rootNode.SelectSingleNode() instead of bookResult.SelectSingleNode().

Having said that, your xml segment is not well formed, and it is not clear if the entire xml content will give you anything sensible.
slayasty 26-Dec-13 16:08pm    
I see. Well im a newbie at coding so its expected that the form is not good. thanks for the extra hand

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900