I successfully added HtmlAgilityPack to my project. However, I tried the following code to extract the body text:
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
// There are various options, set as needed
// filePath is a path to a file containing the html
// Use: htmlDoc.LoadXML(xmlString); to load from a string
// ParseErrors is an ArrayList containing any errors from the Load statement
if (htmlDoc.ParseErrors!=null && htmlDoc.ParseErrors.Count>0)
// Handle any parse errors as required
if (htmlDoc.DocumentNode != null)
HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
if (bodyNode != null)
// Do something with bodyNode
and I receive the following error when building the project.
Error 1 The type 'System.Xml.XPath.IXPathNavigable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.XPath, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Can you please let me know what the issue is? Thanks for the help.