Click here to Skip to main content
15,923,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is really eluding me and I have no idea how to get this *single* value when parsing the html code. There has got a way to get it using HtmlAgility.
XML
<td class="bodyTextSmall" valign="bottom">
    |
    |--#text[1]:
    |
    |--<b>
    |   |
    |   --#text[1]: Qty In Stock:
    |
    |--#text[2]:  188
    |
    |--<br>
    |
    |--#text[3]:
    |


This is the best I can do to demonstrate how the tree looks, after I use

./td which brings me at the top of this line

XML
<td class="bodyTextSmall" valign="bottom">


the question remains on how to get the #text value, I don't need them all I just need one value which has the 188
Posted
Comments
LLLLGGGG 7-Jun-15 3:20am    
Have you tried to download the page and use Regex to find it?
Kornfeld Eliyahu Peter 7-Jun-15 4:50am    
All those text are under a single TD?
theadmin 7-Jun-15 11:00am    
I ended up doing the following and it seemed to work.

string instock = string.Empty;
foreach (HtmlNode node in row.SelectNodes("./td[3]/text()"))
{
instock = node.InnerText;
if (instock.IndexOf("nbsp;") > -1)
{
instock = instock.Replace("nbsp;", "");
break;
}
}

I don't know if this is the best way but its working.
LLLLGGGG 7-Jun-15 14:42pm    
If it works put it as a solution and mark the thread as solved in order to make everybody understand that you do not need help anymore. :-)
theadmin 7-Jun-15 14:51pm    
Thanks...

1 solution

I ended up doing the following and it seemed to work.

C#
string instock = string.Empty;
 foreach (HtmlNode node in row.SelectNodes("./td[3]/text()"))
 {
 instock = node.InnerText;
 if (instock.IndexOf("nbsp;") > -1)
 {
 instock = instock.Replace("nbsp;", "");
 break;
 }
 }
 
Share this answer
 

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