Reputation: 1147
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
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