HtmlAgility和#text [] [英] HtmlAgility and #text[]
本文介绍了HtmlAgility和#text []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在解析html代码时,我真的不知道如何获得这个* 单 *值。有一种方法可以使用HtmlAgility来获取它。
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.
<td class="bodyTextSmall" valign="bottom">
|
|--#text[1]:
|
|--<b>
| |
| --#text[1]: Qty In Stock:
|
|--#text[2]: 188
|
|--<br>
|
|--#text[3]:
|
这是我能做的最好的演示在我使用后,树看起来怎么样?
./td让我在这条线的顶部
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
<td class="bodyTextSmall" valign="bottom">
问题仍然是如何获得#text值,我不需要它们我只需要一个具有 188
推荐答案
我最终做了以下操作,似乎工作正常。
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;
}
}
这篇关于HtmlAgility和#text []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文