C# 如何使用html敏捷性在两个特殊html标记之间查找文本

C# 如何使用html敏捷性在两个特殊html标记之间查找文本,c#,html-agility-pack,C#,Html Agility Pack,我试图使用html agility c#提取网页中和之间的所有文本,但我不知道xpath是什么 如何在此html标记之间查找文本: <span class="a-title-heade a-step-one a-text-normal" dir="auto"> Science is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and p

我试图使用html agility c#提取网页中和之间的所有文本,但我不知道xpath是什么

如何在此html标记之间查找文本:

<span class="a-title-heade a-step-one a-text-normal" dir="auto">
Science is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe
</span>

科学是一项系统性的事业,它以可测试的解释和对宇宙的预测的形式建立和组织知识

您可以使用“选择节点”来选择所需的节点

var html =@"<span class=""a-title-heade a-step-one a-text-normal"" dir=""auto"">Science is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe</ span > ";

var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);

var node = htmlDoc.DocumentNode.SelectNodes("//span").FirstOrDefault();

string name = node.InnerText;
Console.WriteLine(name);
var html=@“科学是一项系统的事业,它以可测试的解释和对宇宙的预测的形式构建和组织知识”;
var htmlDoc=新的HtmlDocument();
htmlDoc.LoadHtml(html);
var node=htmlDoc.DocumentNode.SelectNodes(“//span”).FirstOrDefault();
字符串名称=node.InnerText;
Console.WriteLine(名称);

您可以使用“选择节点”来选择所需的节点

var html =@"<span class=""a-title-heade a-step-one a-text-normal"" dir=""auto"">Science is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe</ span > ";

var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);

var node = htmlDoc.DocumentNode.SelectNodes("//span").FirstOrDefault();

string name = node.InnerText;
Console.WriteLine(name);
var html=@“科学是一项系统的事业,它以可测试的解释和对宇宙的预测的形式构建和组织知识”;
var htmlDoc=新的HtmlDocument();
htmlDoc.LoadHtml(html);
var node=htmlDoc.DocumentNode.SelectNodes(“//span”).FirstOrDefault();
字符串名称=node.InnerText;
Console.WriteLine(名称);

谢谢,如果有多个文本@shahraiz Kayani,如何提取所有文本谢谢,如果有多个文本@shahraiz Kayani,如何提取所有文本你的问题没有意义。。在那一段中有一段文字。。你说的所有文本是什么意思?你能在你的问题中详细说明吗?谢谢,如果有多个文本@shahraiz Kayani,如何提取所有文本谢谢,如果有多个文本@shahraiz Kayani,如何提取所有文本你的问题没有意义。。在那一段中有一段文字。。你说的所有文本是什么意思?您能在问题中详细说明一下吗?您可能希望包含HTML的完整结构,以便提供有效的XPath。您可能希望包含HTML的完整结构,以便提供有效的XPath。