1
我有HTML字符串像這樣(雅虎XML描述元素)HTML Agilty包和字符串解析?
<img src="http://l.yimg.com/a/i/us/we/52/26.gif"/><br />
<b>Current Conditions:</b><br /> Cloudy, 1 C<BR /> <BR />
<b>Forecast:</b><BR /> Mon - Snow. High: -5 Low: -14<br /> Tue - Light Snow. High: -8 Low: -16<br /> <br />
....
我想只有高低值(對於上面的例子:-5,-14,-8,-16)
我嘗試用htmlAgilityPack得到這樣的:
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(rssDescriptionElement);
List<string> elements = new List<string>();
foreach (HtmlNode element in htmlDoc.DocumentNode.SelectNodes("//br"))
{
elements.Add(element.NextSibling.InnerText);
}
elements
列表輸出上面htmlString:
"\n"
"\nCloudy, 1 C"
"\n"
"Forecast:"
"\nMon - Snow. High: -5 Low: -14"
"\nTue - Light Snow. High: -8 Low: -16"
"\n"
"\n"
""
"\n(provided by "
"\n"
如何從此列表中只能得到高值和低值(-5,-14,-8,-16)還是另一種不同的解決方案?