Reputation: 51
This is Xml where i want to select meta tag
<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">
I am doing this
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);
}
Its not actually selecting any text from there............what i am doing wrong please help
Upvotes: 0
Views: 240
Reputation: 12114
meta
elements are self-closing elements, meaning they have no text children (InnerText). I believe you want to get the value of the content
attribute. I believe you do that using something like SN["content"]
, but I don't know HtmlAgilityPack.
Upvotes: 2