argoneus
argoneus

Reputation: 1147

How to get a site element value?

I ran into a site with the following html line:

<span id="isLive" style="display:none;">true</span>

Thing is, I didn't really need to find its value until now, usually parameters were fine so I'm at a loss here. How do I get the 'true' or 'false' if the span with id isLive is unique as in one per site?

Thank you!

Upvotes: 0

Views: 45

Answers (1)

dtsg
dtsg

Reputation: 4468

Using HTML Agility Pack:

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(//Load document);

var isLive = doc.DocumentNode.Descendants("span").Where(d => d.Attributes.Contains("id") && d.Attributes["id"].Value.Contains("isLive")).SingleOrDefault();

string result = isLive.InnerText;

Upvotes: 1

Related Questions