HTMLAgilityPack C#,如何从 DIV 中的嵌套标签中提取文本
HTMLAgilityPack C#, How to extract text from nested Tags in DIV
我有这个 HTML 代码,我想从中提取日期:
<div id="footer">
<div style="font-size:smaller">
Added in:
<strong>
07/06/2021 2:15:36 PM
</strong>
</div>
</div>
这是我的 C# HTMLAgilityPack
doc.DocumentNode.SelectSingleNode("//div[@id='footer']").InnerText
doc.DocumentNode.SelectSingleNode("//div[@id='footer']/div/strong").InnerText
更新:
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;
我提取了日期
我有这个 HTML 代码,我想从中提取日期:
<div id="footer">
<div style="font-size:smaller">
Added in:
<strong>
07/06/2021 2:15:36 PM
</strong>
</div>
</div>
这是我的 C# HTMLAgilityPack
doc.DocumentNode.SelectSingleNode("//div[@id='footer']").InnerText
doc.DocumentNode.SelectSingleNode("//div[@id='footer']/div/strong").InnerText
更新:
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;
我提取了日期