Reputation: 1564
I want to get the ISO Language Code from the html tag with html-agility-pack.
My code looks like
var web = new HtmlWeb
{
UserAgent = "[Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/10.0]"
};
var doc = web.Load(url);
string lang = doc.DocumentNode.SelectSingleNode("//html").InnerText;
But this gets of course the full html content.
So how to enter these tag?
<html lang="en">
edit:
DocumnetNode has no Attributres
Upvotes: 0
Views: 556
Reputation: 2434
You should be able to get the language with the following code. It will get the html
node and get the value of the lang
attribute on that.
string language = doc.DocumentNode.SelectSingleNode("//html").Attributes["lang"].Value;
Upvotes: 2