HtmlAgilityPack을 사용하여 HTML에서 텍스트를 추출하려고합니다. 내 프로젝트에 HtmlAgilityPack을 추가했습니다. 그러나 본문 텍스트를 추출하려면 다음 코드를 시도했습니다.HtmlAgilityPack을 사용하여 WP7에서 HTML에서 텍스트 가져 오기
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
}
}
}
및 프로젝트를 빌드 할 때 다음 오류가 나타납니다.
오류 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 참조를 추가했음을 추가해야하며이 오류가 계속 발생합니다. 이 문제를 도와 주실 수 있습니까? 감사.
전화로 HAP을 사용하면 구문 분석 된 HTML에서 물건을 찾기 위해 Linq2Xml을 사용해야합니다. –
가능한 [WP7.5에 HTML 민첩성 팩 사용] (http://stackoverflow.com/questions/8454959/using-html-agility-pack-on-wp7-5) –