Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I installed htmlagility pack and developed a new program but when I run the program. I have the following error.

The type 'System.Xml.XPath.IXPathNavigableS' 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'

I searched System.Xml.Xpath dll in C:\Program Files\Microsoft SDKs and there is no Silverlight folder and no dll. I installed Silverlight 5.1. When I searched it in C:\Program Files\Microsoft Silverlight\5.1.10411.0, I only found System.Xml.dll but no xpath.dll. The program is in VS 2008 and window XP. Please give me any suggestions to move on and start using htmlagilitypack.

Thanks.
Posted

Hi
I think the
C#
System.Xml.XPath
namespace coming under
C#
System.Xml.dll
This dll you can find in the folder

C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client


C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client


Or you can just use Visual Studio Project -> Right Click -> AddReference -> .NET -> System.Xml.dll to find dll.

Can you please check in the below mentioned folder also.

C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client
There you can find a dll named
System.Xml.XPath.dll



Regards
Dominic
 
Share this answer
 
v2
Comments
MI12344 3-Dec-12 1:04am    
Thanks, but I cannot find the System.Xml.Xpath dll file but when I added Xml to the Add reference, I can use it as System.Xml.Xpath. But when I run this program, it still shows me that error. I followed the web scrapper tutorial from this site http://www.notonlycoder.com/blog/web-scraping-tutorial-c-part-2-get-html-manage-speed-and-timeout/
MI12344 3-Dec-12 1:04am    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using HtmlAgilityPack;
using System.Xml.XPath;

namespace DictateConverter.HtmlScraper.Request
{
class HtmlScraper
{
private static HtmlDocument getHtmlDocumentWebClient(string url, bool useProxy, string proxyIp, int proxyPort, string usename, string password)
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
client.Credentials = CredentialCache.DefaultCredentials;
client.Proxy = WebRequest.DefaultWebProxy;

if (useProxy)
{
//Proxy
if (!string.IsNullOrEmpty(proxyIp))
{
WebProxy p = new WebProxy(proxyIp, proxyPort);
if (!string.IsNullOrEmpty(usename))
{
if (password == null)
password = string.Empty;
NetworkCredential nc = new NetworkCredential(usename, password);
p.Credentials = nc;
}
}
}

Stream data = client.OpenRead(url);
doc.Load(data);
data.Close();
return doc;

}

public static HtmlDocument GetHtmlDoc(string url, Dictate360Converter.Request.Options options, ProxyModel proxy)
{
try
{
if (options != null)
{
if (options.Request_pause_milliseconds >= 0)
System.Threading.Thread.Sleep(options.Request_pause_milliseconds);
}

//Execute WITH Proxy
if (proxy != null)
{
//if proxy ip is empty use standard request
if (proxy.Ip.ToLower() != "")
{
return getHtmlDocumentWebClient(url, true, proxy.Ip, Int32.Parse(proxy.Port), proxy.Username, proxy.Password);
}
else
{ return getHtmlDocumentWebClient(url, false, string.Empty, 0, string.Empty, string.Empty); }

}
else return getHtmlDocumentWebClient(url, false, String.Empty, 0, String.Empty, String.Empty);
}

catch (TimeoutException tEx)
{
System.Threading.Thread.Sleep(options.Pause_after_timeout_milliseconds);
Logger.Instance.Log.Error(string.Format("TimeoutException : Noc.HtmlScraper.Request.Load.GetHtmlDoc({0},options,proxies)", url), tEx);
return null;
}
catch (Exception ex)
{
Logger.Instance.Log.Error(string.Format("Noc.HtmlScraper.Request.Load.GetHtmlDoc({0},options,proxies)", url), ex);
return null;
}

}
}
}
Hi
Sorry i couldn't find any solution other than referring the dll.
C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Xml.XPath.dll
Can you search in your system for this dll ? Sometimes the location you are trying to find the dll may be wrong.

Others may come with a better solution. All the best !!


Regards
Dominic
 
Share this answer
 
Comments
MI12344 3-Dec-12 4:41am    
Yes, I found it on my laptop, but there is no Silverlight\v4.0 folder on my work desktop. It has really given me trouble. Thanks for your solution.
Dominic Abraham 3-Dec-12 5:01am    
Nice !!!
If the solution is helpful don't forget to mark it as answer. So that it may help others with similar issues.
MI12344 4-Dec-12 1:29am    
Even if Siliverlight 5.1 was removed and 4.0 installed again on Window Xp, I cannot still find System.Xml.Xpath. I only found System.Xml. Is it related with VS 2008 platform?
Dominic Abraham 4-Dec-12 6:32am    
"C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\" .
This folder exists in your system?
No, I do not. I just realized that VS 2008 comes with Silverlight 2.0. So I installed v 2.0 and there is C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client, but there is no System.Xml.Xpath.dll file. No SYSTEM.XML.XPATH dll in VS 2008 and silverlight 2.0!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900