This project has moved and is read-only. For the latest updates, please go here.

Using HTML Agility Pack with WP7.5

Topics: Developer Forum, User Forum
Dec 10, 2011 at 6:25 AM


I'm trying to compile the source for WP7.5. Is there a guide or a reference to follow for compiling the source for WP7.5? I'm trying to extract the text from a given URL and I would want my WP7 app to do that.



Dec 10, 2011 at 12:41 PM

There is w WP 7.5 binary available in the Nuget package

Dec 10, 2011 at 1:10 PM

Thanks a lot. Will look into it and give an update.

Dec 10, 2011 at 1:55 PM

I successfully added HtmlAgilityPack to my project. However, I tried the following code to extract the body text:

 HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

// There are various options, set as needed

// filePath is a path to a file containing the html

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


if (htmlDoc.DocumentNode != null)
HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");

if (bodyNode != null)
// Do something with bodyNode

and I receive the following error when building the project. 

Error 1 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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. D:\test\test\MainPage.xaml.cs 58


Can you please let me know what the issue is? Thanks for the help.

Dec 10, 2011 at 3:21 PM

Reference the System.Xml assembly in the project that is using the agility pack would be my first guess. I was going to say perhaps the internal library isn't but it is according to the latest source. Are you using this in an internal say Core project? Usually the Silverlight app projects reference System.Xml for you but not the Library projects if I recall correctly.

Dec 10, 2011 at 3:27 PM

I followed the nuget method of installing HtmlAgility Pack and in fact added the System.Xml reference again after I received this error. However, I still get the same error although I've referenced the library from my project. Can you elaborate on what you meant when you said abt a core project? I am developing a WP7 app using the Silverlight framework for Win Phones. This is just a part of the code I'm trying to work with. Can you let me know where to find the library projects? Yes, I did find System.Xml being referenced already and I added it again just out of curiosity although it went in vain. Thanks.

Dec 10, 2011 at 4:25 PM

I got same error 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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Dec 10, 2011 at 5:19 PM

Found working version here -

Dec 10, 2011 at 6:43 PM

add a reference to System.Xml.XPath that comes with the Silverlight 4 SDK. WP7 Mango is compatible with SL4 libraries . The dll can be found at C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client on X64 systems

Dec 11, 2011 at 2:05 AM

Thanks @darthobiwan. I rectified issue with referencing and I'm able to build and run my project without errors.

Dec 24, 2011 at 10:28 AM

Thank you very much @ep_wp7.

May 25, 2013 at 4:28 PM
Thanks. That sorted it for me darthobiwan!