Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用c在HTML中获取特定文本?_C#_Asp.net_.net - Fatal编程技术网

C# 如何使用c在HTML中获取特定文本?

C# 如何使用c在HTML中获取特定文本?,c#,asp.net,.net,C#,Asp.net,.net,如何从下面的HTML中获取文本吸引力 <li class="product"> <strong> <a href="http://[SITENAME]/id=23423">Attractions</a> </strong> <span></span> </li> 我该怎么做 Result = htmlDocument.DocumentNode.SelectS

如何从下面的HTML中获取文本吸引力

<li class="product">
     <strong>
        <a href="http://[SITENAME]/id=23423">Attractions</a>
    </strong>
    <span></span>
</li>
我该怎么做

Result = htmlDocument.DocumentNode.SelectSingleNode("//li[@class='product']/strong/a").InnerText;

您还可以使用SelectNodes进行foreach操作,就像您在上面所做的一样。

难道您不知道如何提问吗?
Result = htmlDocument.DocumentNode.SelectSingleNode("//li[@class='product']/strong/a").InnerText;