Z.Example.SelectSingleNode

CSharp · Console

/Program.cs

// @nuget: HtmlAgilityPack
using System;
using HtmlAgilityPack;
				
public class Program
{
	public static void Main()
	{
		var html = 
		@"
		<p class=""pclass"">
  			France<br />
  			<span class=""sclass1"">COOK & SHARE</span><br />
  			<span class=""sclass2"">Hall</span>
		</p>";
     	var htmlDoc = new HtmlDocument();
     	htmlDoc.LoadHtml(html);
		var node = htmlDoc.DocumentNode.SelectSingleNode("p[@class='pclass']");
		Console.WriteLine(node.InnerHtml);
	}
}
;