Kar*_*tos 2 c# windows-phone-7 html-agility-pack
我正在尝试使用HtmlAgilityPack从HTML中提取文本.我成功地将HtmlAgilityPack添加到了我的项目中.但是,我尝试使用以下代码来提取正文:
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
// There are various options, set as needed
htmlDoc.OptionFixNestedTags=true;
// filePath is a path to a file containing the html
htmlDoc.Load(filePath);
// 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
}
else
{
if (htmlDoc.DocumentNode != null)
{
HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
if (bodyNode != null)
{
// Do something with bodyNode
}
}
}
Run Code Online (Sandbox Code Playgroud)
并且在构建项目时收到以下错误.
错误1类型'System.Xml.XPath.IXPathNavigable'在未引用的程序集中定义.您必须添加对程序集'System.Xml.XPath,Version = 2.0.5.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'的引用.D:\ test\test\MainPage.xaml.cs 58
我应该补充一点,我添加了System.Xml引用,但仍然出现此错误.你能帮我解决一下这个问题吗?谢谢.