Reputation: 1423
I have html code with this element.
<span itemprop="datePublished" content="2016-06-18T00:44:00+06:00">০০:৪৫, জুন ১৮, ২০১৬</span>
With Agility Pack
I want value "2016-06-18T00:44:00+06:00" of Attribute content
. I can select InnerText with this code:
HtmlDocument.DocumentNode.SelectSingleNode("//span[@itemprop='datePublished']");
Upvotes: 0
Views: 45
Reputation: 89285
Use GetAttributeValue(attrName, defaultVal)
method which return attribute value of name attrName
if it exists, and return defaultVal
otherwise :
var span = HtmlDocument.DocumentNode.SelectSingleNode("//span[@itemprop='datePublished']");
var content = span.GetAttributeValue("content", "");
Upvotes: 1