我想創建一個應用程序,它從網頁中獲取某些內容並將其顯示給用戶。爲了做這件事,我使用了HtmlAgilityPack。我添加了對項目的引用(來自NuGet的1.4.6.0版),並且我使用了幾年前用戶在另一個問題中發佈的代碼。使用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);
if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
{
// Handle any parse errors as required
}
else
{
if (htmlDoc.DocumentNode != null)
{
HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
if (bodyNode != null)
{
// Do something with bodyNode
}
}
}
我的問題是,我得到以下錯誤:
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=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
所以我試着用以下的dll添加引用:
c:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client\System.Xml.XPath.dll
但這次我得到以下錯誤(我翻譯它,因爲我得到一個意大利的錯誤,所以它可能不是正確的翻譯):
It is not possible to add a reference to an assembly to the project that is not compatible or of an above version
我能做什麼?
這是Windows Phone 8.1 silverlight應用程序或Windows手機應用程序商店的應用程序? – har07