Question

My code is this:

namespace MyNSpace
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        async private void ButtonParse_Click(object sender, RoutedEventArgs e)
        {
            HttpClient client = new HttpClient();
            var doc = new HtmlAgilityPack.HtmlDocument();
            string url = "www.mysite.com";
            string html = await client.GetStringAsync(url);
            doc.LoadHtml(html);
            HtmlNodeCollection tl = doc.DocumentNode.SelectNodes("//div[@class=\"photo\"]/a/img");
            //I must still write this part
        }
    }
}

I get this error on the var doc = new HtmlAgilityPack.HtmlDocument(); line:

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,

Why? I read that people got this problem if they didn't load a certain System.Xml.XPath.dll both manually and writing the Using line. If I try to import the DLL manually, I get an error that I'm trying to add a reference to an assembly that is not compatible. It's the first time I'm programming for Windows Phone, so I won't be surprised if it's a little problem.

No correct solution

OTHER TIPS

Make sure you added reference to Silverlight version of System.Xml.XPath.dll. That's required to use HtmlAgilityPack in Windows Phone Project.

I've tested with Windows Phone 7.5 only, but based on this article it seems to be working for Windows Phone 8 project too (see Article Metadata > Compatibility Platform(s) section in that link). In my case the .dll resides in this path :

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top