2014-07-21 5 views
0

웹 페이지에서 무언가를 가져 와서 사용자에게 보여주는 앱을 만들고 싶습니다. 이 일을하기 위해서, 나는 HtmlAgilityPack을 사용했다. 프로젝트 (NuGet의 1.4.6.0 버전)에 대한 참조를 추가했으며 몇 년 전에 사용자가 다른 질문에 게시 한 코드를 사용했습니다. HtmlAgilityPack을 사용하여 조립 오류가 발생했습니다.

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

을하지만 난 얻을이 시간은 다음과

  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 
        } 
       } 
      } 

내 문제는 내가 다음과 같은 오류를 얻을 수 있다는 것입니다 오류 (이탈리아어 오류가 발생하여 번역되었으므로 올바른 번역이 아닐 수 있습니다.)

It is not possible to add a reference to an assembly to the project that is not compatible or of an above version

무엇을 할 수 있습니까?

+1

Windows Phone 8.1 실버 라이트 앱입니까, 아니면 Windows Phone 스토어 앱입니까? – har07

답변

0

Windows Phone 8.1 저장소 앱의 HtmlAgilityPack (HAP)은 HAP for Windows 8 store apps과 비슷한 XPath를 지원하지 않는 것 같습니다. 이 경우

, 당신은 예를 들어 HAP의 LINQ의 API 대신의 XPath API를 사용할 수 있습니다

...... 
if (htmlDoc.DocumentNode != null) 
{ 
    HtmlAgilityPack.HtmlNode bodyNode = doc.DocumentNode 
              .DescendantsAndSelf("body") 
              .FirstOrDefault(); 
    if (bodyNode != null) 
    { 
     // Do something with bodyNode 
    } 
} 
...... 

을 실제로 전화 실버 라이트 애플리케이션 프로젝트, LINQ의 API는 여전히 가능한 해결 방법입니다 창문이 경우에도 마찬가지입니다.