这是Xml,我想选择元标记
<meta charset="utf-8">
<title>Gmail: Email from Google</title>
<meta name="description" content="10+ GB of storage, less spam,
and mobile access. Gmail is email that's intuitive, efficient, and
useful. And maybe even fun.">
<link rel="icon" type="image/ico" href="//mail.google.com/favicon.ico">
我这样做
string texturl = textBox2.Text;
string Url = "http://" + texturl;
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(Url);
var SpanNodes = doc.DocumentNode.SelectNodes("//meta");
if (SpanNodes != null)
{
foreach (HtmlNode SN in SpanNodes)
{
string text = SN.InnerText;
MessageBox.Show(text);
}
它实际上没有从那里选择任何文本............我做错了请帮助
答案 0 :(得分:2)
meta
元素是自闭元素,意味着它们没有文本子元素(InnerText)。我相信你想获得content
属性的值。我相信你使用像SN["content"]
这样的东西,但我不知道HtmlAgilityPack。