Reputation: 3
I have this HTML code where I want to extract the date from:
<div id="footer">
<div style="font-size:smaller">
Added in:
<strong>
07/06/2021 2:15:36 PM
</strong>
</div>
</div>
This is my C# HTMLAgilityPack
doc.DocumentNode.SelectSingleNode("//div[@id='footer']").InnerText
Upvotes: 0
Views: 86
Reputation: 874
doc.DocumentNode.SelectSingleNode("//div[@id='footer']/div/strong").InnerText
Update :
All Code :
var html ="<div id=\"footer\"><div style=\"font-size:smaller\"> Added in:<strong> 07/06/2021 2:15:36 PM </strong></div></div>";
var doc = new HtmlDocument();
doc.LoadHtml(html);
var time = doc.DocumentNode.SelectSingleNode("//div[@id='footer']/div/strong").InnerText;
and I extracted the Date
Upvotes: 1