When I use XPath to extract data it dosen't give any response in the messagebox.show





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















Anyone can help me I use Copy Xpath in Google chrome tools developement to get this path :






/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]





and I use the path in this code to get data :



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

doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

int i = 2;
while (doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]") != null)
{
string Code_de_ligne = "";
string Numero_de_produit = doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]").InnerText;
string Desc_prod = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[5]/span").InnerText;
string Prix_coutânt = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[7]/span[2]").InnerText;
string Prix_de_vente = "";
string Qte = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[6]/input").GetAttributeValue("value", "");

i++;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


but it doesn't give any response in the MessageBox.Show.



I'm executing XPath against this HTML document:



<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Provincial Tire</title>
<link rel="shortcut icon" href="http://www.provincialtire.net/provt/images/plugin/favicon.ico">
<link href="/designglobal/inosoft/style.css" rel="stylesheet" type="text/css">



<link href="http://www.provincialtire.net/jquery/css/imgpreview.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="http://www.provincialtire.net/jquery/css/thickbox.css" type="text/css" media="screen">
<link href="http://www.provincialtire.net/jquery/css/uploadify.css" rel="stylesheet" type="text/css">
<link href="http://www.provincialtire.net/jquery/css/style.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tablesorter2.min.js"></script>





<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-thickbox.js"></script>






<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tooltips.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.imgpreview.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.uploadify.v2.1.0.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/swfobject.js"></script>














<script type="text/javascript">




function envoieRequete(url,id)
{
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>















<script type="text/javascript">


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}





function envoieRequeteWait(url,id)
{

pausecomp(5);

var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>














<script type="text/javascript">

function envoieRequeteSearch(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<br><br><table align="center" border="0" height="250" width="350" style="background-image:url(/designglobal/inosoft/loading_box.png)"><tr><td align="center"><img src="http://www.provincialtire.net/provt/images/plugins/logoajaxc.gif" ><br><br><b>Please be patient....</b><br></td></tr></table><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;















$(document).ready(function() {
$("table").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
9: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
8: {
// disable it by setting the property sorter to false
sorter: false
}
}

});
});




$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });





}
}
// dans le cas du get



xhr_object.send(null);

}
</script>
















<script type="text/javascript">

function Requete(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<img src="http://www.provincialtire.net/provt/images/pbar.gif" >";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;

}
}
// dans le cas du get



xhr_object.send(null);

}
</script>










<script type="text/javascript">

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;

</script>





<script type="text/javascript">


function toggle(anId)
{
node = document.getElementById(anId);
if (node.style.visibility=="hidden")
{
// caché vers montrer
node.style.visibility = "visible";
node.style.height = "auto";
}
else
{
// visible vers cacher
node.style.visibility = "hidden";
node.style.height = "0";
}
}

</script>





<script type="text/javascript">
function blocknumber(event) {
// Compatibilité IE / Firefox
if(!event&&window.event) {
event=window.event;
}
// IE
if(event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
event.cancelBubble = true;
}
// DOM
if(event.which < 48 || event.which > 57) {
event.preventDefault();
event.stopPropagation();
}
}




function blockletter(evt) {
var e = evt || window.event;
var key = e.keyCode || e.which;

if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
// numbers
key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// Backspace and Tab and Enter
key == 8 || key == 9 || key == 13 ||
// Home and End
key == 35 || key == 36 ||
// left and right arrows
key == 37 || key == 39 ||
// Del and Ins
key == 46 || key == 45 ||
// point .
key == 110) {
// input is VALID
}
else {
// input is INVALID
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
}
}

</script>



<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
theUrl = 'http://www.provincialtire.net/search.html';

setTimeout("location.replace(theUrl);",timeoutPeriod);
}
// JavaScript:timedRefresh(1000000); -->
</script>




<script>
function SendInfo(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
envoieRequeteSearch('modules/searchajax.php?size='+form1.size.value+'&manu='+form1.manu.value+'&desc='+form1.desc.value+'&type='+form1.type.value+'&nostock='+form1.nostock.checked+'&prodno='+form1.prodno.value+'&tri='+form1.tri.value+'&cache='+form1.cache.checked,'conteneur');

}

}
</script>

















<script type="text/javascript">if (window != top) top.location.href = location.href;</script>
<noscript>
You do Activate JavaScript on your Brwoser / Vous devez activer le JavaScript de votre navigateur
</noscript>


</head>

<body onload=" ">





<table width="960" border="0" align="center">
<tbody><tr>
<td>


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">


<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-image:url(http://www.provincialtire.net/provt/images/plugins/toplogo.jpg)">
<tbody><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="392" height="110">

<div style="position:relative;">

<div style="position:absolute; bottom:35px; right:5px;">
<a href="exit-en.html"> <img src="http://www.provincialtire.net/images/error.png" title="Exit"> </a>
</div>

</div>


</td>
</tr>
</tbody></table>

</td>
</tr>
</tbody></table>


<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top" background="/designglobal/inosoft/background.jpg" style="background-repeat:no-repeat;" bgcolor="#ffffff">
















<div style="position:relative; top:-5px;">

<table style="background-image:url(/designglobal/inosoft/top_menu_button.jpg)" border="0" cellspacing="0" cellpadding="0" height="45" id="cellule_menu_principal">
<tbody><tr>


<td width="50" align="center" class="menu_principal">&nbsp; </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="/">Informations</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="promotions-en.html">Promotions</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="color:#FF0000" href="search-en.html">Search <br> Products</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="acount-en.html">Your Account</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="storage-en.html">Your<br>Storage</a> </td>

<td width="96" align="center" class="menu_principal">
&nbsp;
</td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tracking-en.html">Track Shipments</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tools-en.html">Tools</a> </td>

<td width="80" align="center" class="menu_principal"><a href="modules/rma.php?l=en&amp;noclient=73742&amp;keepThis=true&amp;TB_iframe=true&amp;height=350&amp;width=475" title="RMA" class="thickbox">
RMA </a></td>

<td width="96" align="center" class="menu_principal"> <a style="" href="contact-en.html">Contact Us</a> </td>
</tr>


</tbody></table>

</div>


















<table width="100%" height="1000" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td width="15">&nbsp;</td>
<td class="texte" valign="top"><br>












<table width="100%" border="0" cellpadding="0">
<tbody><tr>
<td width="120">



<table height="36" border="0" cellpadding="0" cellspacing="0" background="http://www.provincialtire.net/provt/images/topbutton/img_fond_titre.jpg">
<tbody><tr>
<td valign="middle" class="titre"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_gauche_titre.jpg" width="12" height="39"></td>
<td valign="top" class="titre"><table border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td height="5"></td>
</tr>
<tr>
<td>

Order
</td>
</tr>
</tbody></table></td>
<td width="16" align="right" valign="middle"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_droit_titre.jpg" width="12" height="39"></td>
</tr>
</tbody></table>


</td>


<td>&nbsp;











</td>





</tr>
</tbody></table>






<br>




<table width="100%" cellpadding="4" cellspacing="4"><tbody><tr><td>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<a style="color:#FFFFFF" href="/?ordernow=y&amp;rem=all">Delete All Products</a>



&nbsp;



</div> <div class="b"> <div> </div> </div> </div>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFD700" width="100%"><tbody><tr valign="top"><td valign="top">

&nbsp;&nbsp;<br><table class="tablemasterbleue" style="font-size:11px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr class="headerlist">
<td width="100" align="center">Prod #</td>
<td width="100" align="center">Manufacturer</td>
<td width="75" align="center">Qty</td>
<td width="35"></td>
<td width="35"></td>
<td width="">Description</td>
<td width="35"></td>
<td width="100" align="center">Price</td>
</tr>


<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr><tr class="headerlist"><td colspan="8">

<table width="100%" style="font-size:12px; font-weight:bold;" border="0">
<tbody><tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">HST</td>
<td width="25">

<div id="tps">

49.4
</div>



</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50"></td>
<td width="25">


<div id="tvq">





</div>


</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">TOTAL</td>
<td width="25">
<div id="total">
429.4
</div>
</td>
</tr>
</tbody></table>

</td></tr>

</tbody></table>






</td></tr></tbody></table>


<br><br>






</div> <div class="b"> <div> </div> </div> </div>

</td></tr>

<tr><td>


</td></tr>

<tr><td>
<form id="form1" name="form1" method="post" action="/sendorder-en.html">

<div class="dialog"> <div class="boxContent"> <div class="t"></div>


<table style="color:#FFFFFF" width="100%" border="0" cellpadding="3" cellspacing="5">


<tbody><tr>
<td colspan="2" align="right">




<br><b>This order does not apply to a national account<b><br><input type="hidden" value="n" name="clinat" id="clinat">






</b></b></td>
</tr>


<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="50%"><b>Delivery Instruction: </b></td>
<td width="50%"><input type="hidden" value="y" name="basketsend" id="basketsend"><input type="hidden" value="y" name="type" id="type"></td>
</tr>
<tr>
<td rowspan="3" align="left" valign="top"><label>
<input name="instruction" type="text" id="instruction" value="" maxlength="68" size="50">
</label></td>
<td align="right">



<table cellpadding="3" cellspacing="3" border="0">
<tbody><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio1" checked="checked">Next delivery
<input type="radio" name="radio" id="radio" value="radio2">Morning
<input type="radio" name="radio" id="radio" value="radio3">Afternoon
</td>
</tr>

<tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio4">Tomorrow Morning
<input type="radio" name="radio" id="radio" value="radio5">Tomorrow Afternoon
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio8">Standard Delivery
<input type="radio" name="radio" id="radio" value="radio9">Urgent delivery
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio6">Pick Up
<input type="radio" name="radio" id="radio" value="radio7">See Special Instruction
</td>
</tr>
</tbody></table>



</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">Purchase Order :
<label>
<input type="text" name="boncom" id="boncom" maxlength="10">
</label></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right"><input class="normal" width="300px" type="submit" name="buttonsend" id="buttonsend" value="Send" onclick="javascript:this.disabled=true;form1.submit();"></td>
</tr>
</tbody></table>
</div> <div class="b"> <div> </div> </div> </div> </form>
</td></tr></tbody></table>
<br>

<script>
$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });

</script> <br></td>
<td width="15">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody></table>
<table width="960" cellspacing="0" cellpadding="0" class="tablemasterbleueborder" border="3">

<tbody><tr>
<td height="36" align="center" valign="middle" bgcolor="#ffffff">

<table width="100%">
<tbody><tr>
<td align="center">
<a href="http://www.inosoft.ca/english/index.htm"> <img src="images/inosoft-en.jpg" width="125" height="35" alt="InoSoft"> </a>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<br>
<center>
<a href="exit-en.html" style="color:#000">Exit</a>
</center>
<br></td>
</tr>
</tbody></table>
<div id="imgPreviewContainer" style="display: none;"><img style="width: 250px;"></div></body></html>


Here is also screenshot of inspect element : https://i.imgur.com/o59X5wA.png
enter image description here



So I'm going to use the xpath or do I need another solution?



thank you in advance.










share|improve this question

























  • Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

    – Corion
    Nov 22 '18 at 12:24











  • the page use HTML

    – BazSaraa
    Nov 22 '18 at 12:37











  • <td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

    – BazSaraa
    Nov 22 '18 at 12:37











  • Please edit your question and add the additional data there.

    – Corion
    Nov 22 '18 at 12:39











  • i want to add screenshots but they dosen't allow.

    – BazSaraa
    Nov 22 '18 at 12:40


















-1















Anyone can help me I use Copy Xpath in Google chrome tools developement to get this path :






/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]





and I use the path in this code to get data :



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

doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

int i = 2;
while (doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]") != null)
{
string Code_de_ligne = "";
string Numero_de_produit = doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]").InnerText;
string Desc_prod = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[5]/span").InnerText;
string Prix_coutânt = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[7]/span[2]").InnerText;
string Prix_de_vente = "";
string Qte = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[6]/input").GetAttributeValue("value", "");

i++;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


but it doesn't give any response in the MessageBox.Show.



I'm executing XPath against this HTML document:



<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Provincial Tire</title>
<link rel="shortcut icon" href="http://www.provincialtire.net/provt/images/plugin/favicon.ico">
<link href="/designglobal/inosoft/style.css" rel="stylesheet" type="text/css">



<link href="http://www.provincialtire.net/jquery/css/imgpreview.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="http://www.provincialtire.net/jquery/css/thickbox.css" type="text/css" media="screen">
<link href="http://www.provincialtire.net/jquery/css/uploadify.css" rel="stylesheet" type="text/css">
<link href="http://www.provincialtire.net/jquery/css/style.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tablesorter2.min.js"></script>





<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-thickbox.js"></script>






<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tooltips.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.imgpreview.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.uploadify.v2.1.0.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/swfobject.js"></script>














<script type="text/javascript">




function envoieRequete(url,id)
{
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>















<script type="text/javascript">


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}





function envoieRequeteWait(url,id)
{

pausecomp(5);

var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>














<script type="text/javascript">

function envoieRequeteSearch(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<br><br><table align="center" border="0" height="250" width="350" style="background-image:url(/designglobal/inosoft/loading_box.png)"><tr><td align="center"><img src="http://www.provincialtire.net/provt/images/plugins/logoajaxc.gif" ><br><br><b>Please be patient....</b><br></td></tr></table><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;















$(document).ready(function() {
$("table").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
9: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
8: {
// disable it by setting the property sorter to false
sorter: false
}
}

});
});




$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });





}
}
// dans le cas du get



xhr_object.send(null);

}
</script>
















<script type="text/javascript">

function Requete(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<img src="http://www.provincialtire.net/provt/images/pbar.gif" >";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;

}
}
// dans le cas du get



xhr_object.send(null);

}
</script>










<script type="text/javascript">

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;

</script>





<script type="text/javascript">


function toggle(anId)
{
node = document.getElementById(anId);
if (node.style.visibility=="hidden")
{
// caché vers montrer
node.style.visibility = "visible";
node.style.height = "auto";
}
else
{
// visible vers cacher
node.style.visibility = "hidden";
node.style.height = "0";
}
}

</script>





<script type="text/javascript">
function blocknumber(event) {
// Compatibilité IE / Firefox
if(!event&&window.event) {
event=window.event;
}
// IE
if(event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
event.cancelBubble = true;
}
// DOM
if(event.which < 48 || event.which > 57) {
event.preventDefault();
event.stopPropagation();
}
}




function blockletter(evt) {
var e = evt || window.event;
var key = e.keyCode || e.which;

if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
// numbers
key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// Backspace and Tab and Enter
key == 8 || key == 9 || key == 13 ||
// Home and End
key == 35 || key == 36 ||
// left and right arrows
key == 37 || key == 39 ||
// Del and Ins
key == 46 || key == 45 ||
// point .
key == 110) {
// input is VALID
}
else {
// input is INVALID
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
}
}

</script>



<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
theUrl = 'http://www.provincialtire.net/search.html';

setTimeout("location.replace(theUrl);",timeoutPeriod);
}
// JavaScript:timedRefresh(1000000); -->
</script>




<script>
function SendInfo(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
envoieRequeteSearch('modules/searchajax.php?size='+form1.size.value+'&manu='+form1.manu.value+'&desc='+form1.desc.value+'&type='+form1.type.value+'&nostock='+form1.nostock.checked+'&prodno='+form1.prodno.value+'&tri='+form1.tri.value+'&cache='+form1.cache.checked,'conteneur');

}

}
</script>

















<script type="text/javascript">if (window != top) top.location.href = location.href;</script>
<noscript>
You do Activate JavaScript on your Brwoser / Vous devez activer le JavaScript de votre navigateur
</noscript>


</head>

<body onload=" ">





<table width="960" border="0" align="center">
<tbody><tr>
<td>


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">


<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-image:url(http://www.provincialtire.net/provt/images/plugins/toplogo.jpg)">
<tbody><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="392" height="110">

<div style="position:relative;">

<div style="position:absolute; bottom:35px; right:5px;">
<a href="exit-en.html"> <img src="http://www.provincialtire.net/images/error.png" title="Exit"> </a>
</div>

</div>


</td>
</tr>
</tbody></table>

</td>
</tr>
</tbody></table>


<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top" background="/designglobal/inosoft/background.jpg" style="background-repeat:no-repeat;" bgcolor="#ffffff">
















<div style="position:relative; top:-5px;">

<table style="background-image:url(/designglobal/inosoft/top_menu_button.jpg)" border="0" cellspacing="0" cellpadding="0" height="45" id="cellule_menu_principal">
<tbody><tr>


<td width="50" align="center" class="menu_principal">&nbsp; </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="/">Informations</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="promotions-en.html">Promotions</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="color:#FF0000" href="search-en.html">Search <br> Products</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="acount-en.html">Your Account</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="storage-en.html">Your<br>Storage</a> </td>

<td width="96" align="center" class="menu_principal">
&nbsp;
</td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tracking-en.html">Track Shipments</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tools-en.html">Tools</a> </td>

<td width="80" align="center" class="menu_principal"><a href="modules/rma.php?l=en&amp;noclient=73742&amp;keepThis=true&amp;TB_iframe=true&amp;height=350&amp;width=475" title="RMA" class="thickbox">
RMA </a></td>

<td width="96" align="center" class="menu_principal"> <a style="" href="contact-en.html">Contact Us</a> </td>
</tr>


</tbody></table>

</div>


















<table width="100%" height="1000" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td width="15">&nbsp;</td>
<td class="texte" valign="top"><br>












<table width="100%" border="0" cellpadding="0">
<tbody><tr>
<td width="120">



<table height="36" border="0" cellpadding="0" cellspacing="0" background="http://www.provincialtire.net/provt/images/topbutton/img_fond_titre.jpg">
<tbody><tr>
<td valign="middle" class="titre"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_gauche_titre.jpg" width="12" height="39"></td>
<td valign="top" class="titre"><table border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td height="5"></td>
</tr>
<tr>
<td>

Order
</td>
</tr>
</tbody></table></td>
<td width="16" align="right" valign="middle"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_droit_titre.jpg" width="12" height="39"></td>
</tr>
</tbody></table>


</td>


<td>&nbsp;











</td>





</tr>
</tbody></table>






<br>




<table width="100%" cellpadding="4" cellspacing="4"><tbody><tr><td>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<a style="color:#FFFFFF" href="/?ordernow=y&amp;rem=all">Delete All Products</a>



&nbsp;



</div> <div class="b"> <div> </div> </div> </div>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFD700" width="100%"><tbody><tr valign="top"><td valign="top">

&nbsp;&nbsp;<br><table class="tablemasterbleue" style="font-size:11px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr class="headerlist">
<td width="100" align="center">Prod #</td>
<td width="100" align="center">Manufacturer</td>
<td width="75" align="center">Qty</td>
<td width="35"></td>
<td width="35"></td>
<td width="">Description</td>
<td width="35"></td>
<td width="100" align="center">Price</td>
</tr>


<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr><tr class="headerlist"><td colspan="8">

<table width="100%" style="font-size:12px; font-weight:bold;" border="0">
<tbody><tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">HST</td>
<td width="25">

<div id="tps">

49.4
</div>



</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50"></td>
<td width="25">


<div id="tvq">





</div>


</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">TOTAL</td>
<td width="25">
<div id="total">
429.4
</div>
</td>
</tr>
</tbody></table>

</td></tr>

</tbody></table>






</td></tr></tbody></table>


<br><br>






</div> <div class="b"> <div> </div> </div> </div>

</td></tr>

<tr><td>


</td></tr>

<tr><td>
<form id="form1" name="form1" method="post" action="/sendorder-en.html">

<div class="dialog"> <div class="boxContent"> <div class="t"></div>


<table style="color:#FFFFFF" width="100%" border="0" cellpadding="3" cellspacing="5">


<tbody><tr>
<td colspan="2" align="right">




<br><b>This order does not apply to a national account<b><br><input type="hidden" value="n" name="clinat" id="clinat">






</b></b></td>
</tr>


<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="50%"><b>Delivery Instruction: </b></td>
<td width="50%"><input type="hidden" value="y" name="basketsend" id="basketsend"><input type="hidden" value="y" name="type" id="type"></td>
</tr>
<tr>
<td rowspan="3" align="left" valign="top"><label>
<input name="instruction" type="text" id="instruction" value="" maxlength="68" size="50">
</label></td>
<td align="right">



<table cellpadding="3" cellspacing="3" border="0">
<tbody><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio1" checked="checked">Next delivery
<input type="radio" name="radio" id="radio" value="radio2">Morning
<input type="radio" name="radio" id="radio" value="radio3">Afternoon
</td>
</tr>

<tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio4">Tomorrow Morning
<input type="radio" name="radio" id="radio" value="radio5">Tomorrow Afternoon
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio8">Standard Delivery
<input type="radio" name="radio" id="radio" value="radio9">Urgent delivery
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio6">Pick Up
<input type="radio" name="radio" id="radio" value="radio7">See Special Instruction
</td>
</tr>
</tbody></table>



</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">Purchase Order :
<label>
<input type="text" name="boncom" id="boncom" maxlength="10">
</label></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right"><input class="normal" width="300px" type="submit" name="buttonsend" id="buttonsend" value="Send" onclick="javascript:this.disabled=true;form1.submit();"></td>
</tr>
</tbody></table>
</div> <div class="b"> <div> </div> </div> </div> </form>
</td></tr></tbody></table>
<br>

<script>
$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });

</script> <br></td>
<td width="15">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody></table>
<table width="960" cellspacing="0" cellpadding="0" class="tablemasterbleueborder" border="3">

<tbody><tr>
<td height="36" align="center" valign="middle" bgcolor="#ffffff">

<table width="100%">
<tbody><tr>
<td align="center">
<a href="http://www.inosoft.ca/english/index.htm"> <img src="images/inosoft-en.jpg" width="125" height="35" alt="InoSoft"> </a>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<br>
<center>
<a href="exit-en.html" style="color:#000">Exit</a>
</center>
<br></td>
</tr>
</tbody></table>
<div id="imgPreviewContainer" style="display: none;"><img style="width: 250px;"></div></body></html>


Here is also screenshot of inspect element : https://i.imgur.com/o59X5wA.png
enter image description here



So I'm going to use the xpath or do I need another solution?



thank you in advance.










share|improve this question

























  • Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

    – Corion
    Nov 22 '18 at 12:24











  • the page use HTML

    – BazSaraa
    Nov 22 '18 at 12:37











  • <td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

    – BazSaraa
    Nov 22 '18 at 12:37











  • Please edit your question and add the additional data there.

    – Corion
    Nov 22 '18 at 12:39











  • i want to add screenshots but they dosen't allow.

    – BazSaraa
    Nov 22 '18 at 12:40














-1












-1








-1








Anyone can help me I use Copy Xpath in Google chrome tools developement to get this path :






/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]





and I use the path in this code to get data :



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

doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

int i = 2;
while (doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]") != null)
{
string Code_de_ligne = "";
string Numero_de_produit = doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]").InnerText;
string Desc_prod = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[5]/span").InnerText;
string Prix_coutânt = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[7]/span[2]").InnerText;
string Prix_de_vente = "";
string Qte = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[6]/input").GetAttributeValue("value", "");

i++;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


but it doesn't give any response in the MessageBox.Show.



I'm executing XPath against this HTML document:



<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Provincial Tire</title>
<link rel="shortcut icon" href="http://www.provincialtire.net/provt/images/plugin/favicon.ico">
<link href="/designglobal/inosoft/style.css" rel="stylesheet" type="text/css">



<link href="http://www.provincialtire.net/jquery/css/imgpreview.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="http://www.provincialtire.net/jquery/css/thickbox.css" type="text/css" media="screen">
<link href="http://www.provincialtire.net/jquery/css/uploadify.css" rel="stylesheet" type="text/css">
<link href="http://www.provincialtire.net/jquery/css/style.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tablesorter2.min.js"></script>





<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-thickbox.js"></script>






<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tooltips.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.imgpreview.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.uploadify.v2.1.0.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/swfobject.js"></script>














<script type="text/javascript">




function envoieRequete(url,id)
{
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>















<script type="text/javascript">


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}





function envoieRequeteWait(url,id)
{

pausecomp(5);

var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>














<script type="text/javascript">

function envoieRequeteSearch(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<br><br><table align="center" border="0" height="250" width="350" style="background-image:url(/designglobal/inosoft/loading_box.png)"><tr><td align="center"><img src="http://www.provincialtire.net/provt/images/plugins/logoajaxc.gif" ><br><br><b>Please be patient....</b><br></td></tr></table><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;















$(document).ready(function() {
$("table").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
9: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
8: {
// disable it by setting the property sorter to false
sorter: false
}
}

});
});




$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });





}
}
// dans le cas du get



xhr_object.send(null);

}
</script>
















<script type="text/javascript">

function Requete(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<img src="http://www.provincialtire.net/provt/images/pbar.gif" >";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;

}
}
// dans le cas du get



xhr_object.send(null);

}
</script>










<script type="text/javascript">

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;

</script>





<script type="text/javascript">


function toggle(anId)
{
node = document.getElementById(anId);
if (node.style.visibility=="hidden")
{
// caché vers montrer
node.style.visibility = "visible";
node.style.height = "auto";
}
else
{
// visible vers cacher
node.style.visibility = "hidden";
node.style.height = "0";
}
}

</script>





<script type="text/javascript">
function blocknumber(event) {
// Compatibilité IE / Firefox
if(!event&&window.event) {
event=window.event;
}
// IE
if(event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
event.cancelBubble = true;
}
// DOM
if(event.which < 48 || event.which > 57) {
event.preventDefault();
event.stopPropagation();
}
}




function blockletter(evt) {
var e = evt || window.event;
var key = e.keyCode || e.which;

if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
// numbers
key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// Backspace and Tab and Enter
key == 8 || key == 9 || key == 13 ||
// Home and End
key == 35 || key == 36 ||
// left and right arrows
key == 37 || key == 39 ||
// Del and Ins
key == 46 || key == 45 ||
// point .
key == 110) {
// input is VALID
}
else {
// input is INVALID
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
}
}

</script>



<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
theUrl = 'http://www.provincialtire.net/search.html';

setTimeout("location.replace(theUrl);",timeoutPeriod);
}
// JavaScript:timedRefresh(1000000); -->
</script>




<script>
function SendInfo(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
envoieRequeteSearch('modules/searchajax.php?size='+form1.size.value+'&manu='+form1.manu.value+'&desc='+form1.desc.value+'&type='+form1.type.value+'&nostock='+form1.nostock.checked+'&prodno='+form1.prodno.value+'&tri='+form1.tri.value+'&cache='+form1.cache.checked,'conteneur');

}

}
</script>

















<script type="text/javascript">if (window != top) top.location.href = location.href;</script>
<noscript>
You do Activate JavaScript on your Brwoser / Vous devez activer le JavaScript de votre navigateur
</noscript>


</head>

<body onload=" ">





<table width="960" border="0" align="center">
<tbody><tr>
<td>


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">


<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-image:url(http://www.provincialtire.net/provt/images/plugins/toplogo.jpg)">
<tbody><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="392" height="110">

<div style="position:relative;">

<div style="position:absolute; bottom:35px; right:5px;">
<a href="exit-en.html"> <img src="http://www.provincialtire.net/images/error.png" title="Exit"> </a>
</div>

</div>


</td>
</tr>
</tbody></table>

</td>
</tr>
</tbody></table>


<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top" background="/designglobal/inosoft/background.jpg" style="background-repeat:no-repeat;" bgcolor="#ffffff">
















<div style="position:relative; top:-5px;">

<table style="background-image:url(/designglobal/inosoft/top_menu_button.jpg)" border="0" cellspacing="0" cellpadding="0" height="45" id="cellule_menu_principal">
<tbody><tr>


<td width="50" align="center" class="menu_principal">&nbsp; </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="/">Informations</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="promotions-en.html">Promotions</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="color:#FF0000" href="search-en.html">Search <br> Products</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="acount-en.html">Your Account</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="storage-en.html">Your<br>Storage</a> </td>

<td width="96" align="center" class="menu_principal">
&nbsp;
</td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tracking-en.html">Track Shipments</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tools-en.html">Tools</a> </td>

<td width="80" align="center" class="menu_principal"><a href="modules/rma.php?l=en&amp;noclient=73742&amp;keepThis=true&amp;TB_iframe=true&amp;height=350&amp;width=475" title="RMA" class="thickbox">
RMA </a></td>

<td width="96" align="center" class="menu_principal"> <a style="" href="contact-en.html">Contact Us</a> </td>
</tr>


</tbody></table>

</div>


















<table width="100%" height="1000" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td width="15">&nbsp;</td>
<td class="texte" valign="top"><br>












<table width="100%" border="0" cellpadding="0">
<tbody><tr>
<td width="120">



<table height="36" border="0" cellpadding="0" cellspacing="0" background="http://www.provincialtire.net/provt/images/topbutton/img_fond_titre.jpg">
<tbody><tr>
<td valign="middle" class="titre"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_gauche_titre.jpg" width="12" height="39"></td>
<td valign="top" class="titre"><table border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td height="5"></td>
</tr>
<tr>
<td>

Order
</td>
</tr>
</tbody></table></td>
<td width="16" align="right" valign="middle"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_droit_titre.jpg" width="12" height="39"></td>
</tr>
</tbody></table>


</td>


<td>&nbsp;











</td>





</tr>
</tbody></table>






<br>




<table width="100%" cellpadding="4" cellspacing="4"><tbody><tr><td>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<a style="color:#FFFFFF" href="/?ordernow=y&amp;rem=all">Delete All Products</a>



&nbsp;



</div> <div class="b"> <div> </div> </div> </div>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFD700" width="100%"><tbody><tr valign="top"><td valign="top">

&nbsp;&nbsp;<br><table class="tablemasterbleue" style="font-size:11px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr class="headerlist">
<td width="100" align="center">Prod #</td>
<td width="100" align="center">Manufacturer</td>
<td width="75" align="center">Qty</td>
<td width="35"></td>
<td width="35"></td>
<td width="">Description</td>
<td width="35"></td>
<td width="100" align="center">Price</td>
</tr>


<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr><tr class="headerlist"><td colspan="8">

<table width="100%" style="font-size:12px; font-weight:bold;" border="0">
<tbody><tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">HST</td>
<td width="25">

<div id="tps">

49.4
</div>



</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50"></td>
<td width="25">


<div id="tvq">





</div>


</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">TOTAL</td>
<td width="25">
<div id="total">
429.4
</div>
</td>
</tr>
</tbody></table>

</td></tr>

</tbody></table>






</td></tr></tbody></table>


<br><br>






</div> <div class="b"> <div> </div> </div> </div>

</td></tr>

<tr><td>


</td></tr>

<tr><td>
<form id="form1" name="form1" method="post" action="/sendorder-en.html">

<div class="dialog"> <div class="boxContent"> <div class="t"></div>


<table style="color:#FFFFFF" width="100%" border="0" cellpadding="3" cellspacing="5">


<tbody><tr>
<td colspan="2" align="right">




<br><b>This order does not apply to a national account<b><br><input type="hidden" value="n" name="clinat" id="clinat">






</b></b></td>
</tr>


<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="50%"><b>Delivery Instruction: </b></td>
<td width="50%"><input type="hidden" value="y" name="basketsend" id="basketsend"><input type="hidden" value="y" name="type" id="type"></td>
</tr>
<tr>
<td rowspan="3" align="left" valign="top"><label>
<input name="instruction" type="text" id="instruction" value="" maxlength="68" size="50">
</label></td>
<td align="right">



<table cellpadding="3" cellspacing="3" border="0">
<tbody><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio1" checked="checked">Next delivery
<input type="radio" name="radio" id="radio" value="radio2">Morning
<input type="radio" name="radio" id="radio" value="radio3">Afternoon
</td>
</tr>

<tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio4">Tomorrow Morning
<input type="radio" name="radio" id="radio" value="radio5">Tomorrow Afternoon
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio8">Standard Delivery
<input type="radio" name="radio" id="radio" value="radio9">Urgent delivery
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio6">Pick Up
<input type="radio" name="radio" id="radio" value="radio7">See Special Instruction
</td>
</tr>
</tbody></table>



</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">Purchase Order :
<label>
<input type="text" name="boncom" id="boncom" maxlength="10">
</label></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right"><input class="normal" width="300px" type="submit" name="buttonsend" id="buttonsend" value="Send" onclick="javascript:this.disabled=true;form1.submit();"></td>
</tr>
</tbody></table>
</div> <div class="b"> <div> </div> </div> </div> </form>
</td></tr></tbody></table>
<br>

<script>
$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });

</script> <br></td>
<td width="15">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody></table>
<table width="960" cellspacing="0" cellpadding="0" class="tablemasterbleueborder" border="3">

<tbody><tr>
<td height="36" align="center" valign="middle" bgcolor="#ffffff">

<table width="100%">
<tbody><tr>
<td align="center">
<a href="http://www.inosoft.ca/english/index.htm"> <img src="images/inosoft-en.jpg" width="125" height="35" alt="InoSoft"> </a>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<br>
<center>
<a href="exit-en.html" style="color:#000">Exit</a>
</center>
<br></td>
</tr>
</tbody></table>
<div id="imgPreviewContainer" style="display: none;"><img style="width: 250px;"></div></body></html>


Here is also screenshot of inspect element : https://i.imgur.com/o59X5wA.png
enter image description here



So I'm going to use the xpath or do I need another solution?



thank you in advance.










share|improve this question
















Anyone can help me I use Copy Xpath in Google chrome tools developement to get this path :






/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]





and I use the path in this code to get data :



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

doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

int i = 2;
while (doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]") != null)
{
string Code_de_ligne = "";
string Numero_de_produit = doc.DocumentNode.SelectSingleNode("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1]").InnerText;
string Desc_prod = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[5]/span").InnerText;
string Prix_coutânt = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[7]/span[2]").InnerText;
string Prix_de_vente = "";
string Qte = doc.DocumentNode.SelectSingleNode("//tbody/tr[" + i + "]/td[6]/input").GetAttributeValue("value", "");

i++;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


but it doesn't give any response in the MessageBox.Show.



I'm executing XPath against this HTML document:



<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Provincial Tire</title>
<link rel="shortcut icon" href="http://www.provincialtire.net/provt/images/plugin/favicon.ico">
<link href="/designglobal/inosoft/style.css" rel="stylesheet" type="text/css">



<link href="http://www.provincialtire.net/jquery/css/imgpreview.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="http://www.provincialtire.net/jquery/css/thickbox.css" type="text/css" media="screen">
<link href="http://www.provincialtire.net/jquery/css/uploadify.css" rel="stylesheet" type="text/css">
<link href="http://www.provincialtire.net/jquery/css/style.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>


<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tablesorter2.min.js"></script>





<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery-thickbox.js"></script>






<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.tooltips.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.imgpreview.js"></script>




<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/jquery.uploadify.v2.1.0.js"></script>
<script type="text/javascript" src="http://www.provincialtire.net/jquery/js/swfobject.js"></script>














<script type="text/javascript">




function envoieRequete(url,id)
{
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>















<script type="text/javascript">


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}





function envoieRequeteWait(url,id)
{

pausecomp(5);

var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);


document.getElementById(position).innerHTML = "<center><img src="http://www.provincialtire.net/provt/images/load.gif" ></center>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{

// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;



}
}
// dans le cas du get


xhr_object.send(null);

}
</script>














<script type="text/javascript">

function envoieRequeteSearch(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<br><br><table align="center" border="0" height="250" width="350" style="background-image:url(/designglobal/inosoft/loading_box.png)"><tr><td align="center"><img src="http://www.provincialtire.net/provt/images/plugins/logoajaxc.gif" ><br><br><b>Please be patient....</b><br></td></tr></table><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;















$(document).ready(function() {
$("table").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
9: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
8: {
// disable it by setting the property sorter to false
sorter: false
}
}

});
});




$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });





}
}
// dans le cas du get



xhr_object.send(null);

}
</script>
















<script type="text/javascript">

function Requete(url,id)
{
var sid = "2nmia7njlrrc8a9mn5199do5d5";
var xhr_object = null;
var position = id;

if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
else
if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

// On ouvre la requete vers la page désirée
xhr_object.open("GET", url, true);
xhr_object.setRequestHeader('Set-Cookie', 'PHPSESSID=' + sid);

document.getElementById(position).innerHTML = "<img src="http://www.provincialtire.net/provt/images/pbar.gif" >";


xhr_object.onreadystatechange = function(){
if ( xhr_object.readyState == 4 )
{


// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
document.getElementById(position).innerHTML = xhr_object.responseText;

}
}
// dans le cas du get



xhr_object.send(null);

}
</script>










<script type="text/javascript">

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;

</script>





<script type="text/javascript">


function toggle(anId)
{
node = document.getElementById(anId);
if (node.style.visibility=="hidden")
{
// caché vers montrer
node.style.visibility = "visible";
node.style.height = "auto";
}
else
{
// visible vers cacher
node.style.visibility = "hidden";
node.style.height = "0";
}
}

</script>





<script type="text/javascript">
function blocknumber(event) {
// Compatibilité IE / Firefox
if(!event&&window.event) {
event=window.event;
}
// IE
if(event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
event.cancelBubble = true;
}
// DOM
if(event.which < 48 || event.which > 57) {
event.preventDefault();
event.stopPropagation();
}
}




function blockletter(evt) {
var e = evt || window.event;
var key = e.keyCode || e.which;

if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
// numbers
key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// Backspace and Tab and Enter
key == 8 || key == 9 || key == 13 ||
// Home and End
key == 35 || key == 36 ||
// left and right arrows
key == 37 || key == 39 ||
// Del and Ins
key == 46 || key == 45 ||
// point .
key == 110) {
// input is VALID
}
else {
// input is INVALID
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
}
}

</script>



<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
theUrl = 'http://www.provincialtire.net/search.html';

setTimeout("location.replace(theUrl);",timeoutPeriod);
}
// JavaScript:timedRefresh(1000000); -->
</script>




<script>
function SendInfo(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
envoieRequeteSearch('modules/searchajax.php?size='+form1.size.value+'&manu='+form1.manu.value+'&desc='+form1.desc.value+'&type='+form1.type.value+'&nostock='+form1.nostock.checked+'&prodno='+form1.prodno.value+'&tri='+form1.tri.value+'&cache='+form1.cache.checked,'conteneur');

}

}
</script>

















<script type="text/javascript">if (window != top) top.location.href = location.href;</script>
<noscript>
You do Activate JavaScript on your Brwoser / Vous devez activer le JavaScript de votre navigateur
</noscript>


</head>

<body onload=" ">





<table width="960" border="0" align="center">
<tbody><tr>
<td>


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">


<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-image:url(http://www.provincialtire.net/provt/images/plugins/toplogo.jpg)">
<tbody><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="392" height="110">

<div style="position:relative;">

<div style="position:absolute; bottom:35px; right:5px;">
<a href="exit-en.html"> <img src="http://www.provincialtire.net/images/error.png" title="Exit"> </a>
</div>

</div>


</td>
</tr>
</tbody></table>

</td>
</tr>
</tbody></table>


<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top" background="/designglobal/inosoft/background.jpg" style="background-repeat:no-repeat;" bgcolor="#ffffff">
















<div style="position:relative; top:-5px;">

<table style="background-image:url(/designglobal/inosoft/top_menu_button.jpg)" border="0" cellspacing="0" cellpadding="0" height="45" id="cellule_menu_principal">
<tbody><tr>


<td width="50" align="center" class="menu_principal">&nbsp; </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="/">Informations</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="promotions-en.html">Promotions</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="color:#FF0000" href="search-en.html">Search <br> Products</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="acount-en.html">Your Account</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="storage-en.html">Your<br>Storage</a> </td>

<td width="96" align="center" class="menu_principal">
&nbsp;
</td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tracking-en.html">Track Shipments</a> </td>

<td width="96" align="center" class="menu_principal"> <a style="" href="tools-en.html">Tools</a> </td>

<td width="80" align="center" class="menu_principal"><a href="modules/rma.php?l=en&amp;noclient=73742&amp;keepThis=true&amp;TB_iframe=true&amp;height=350&amp;width=475" title="RMA" class="thickbox">
RMA </a></td>

<td width="96" align="center" class="menu_principal"> <a style="" href="contact-en.html">Contact Us</a> </td>
</tr>


</tbody></table>

</div>


















<table width="100%" height="1000" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td width="15">&nbsp;</td>
<td class="texte" valign="top"><br>












<table width="100%" border="0" cellpadding="0">
<tbody><tr>
<td width="120">



<table height="36" border="0" cellpadding="0" cellspacing="0" background="http://www.provincialtire.net/provt/images/topbutton/img_fond_titre.jpg">
<tbody><tr>
<td valign="middle" class="titre"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_gauche_titre.jpg" width="12" height="39"></td>
<td valign="top" class="titre"><table border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td height="5"></td>
</tr>
<tr>
<td>

Order
</td>
</tr>
</tbody></table></td>
<td width="16" align="right" valign="middle"><img src="http://www.provincialtire.net/provt/images/topbutton/img_cote_droit_titre.jpg" width="12" height="39"></td>
</tr>
</tbody></table>


</td>


<td>&nbsp;











</td>





</tr>
</tbody></table>






<br>




<table width="100%" cellpadding="4" cellspacing="4"><tbody><tr><td>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<a style="color:#FFFFFF" href="/?ordernow=y&amp;rem=all">Delete All Products</a>



&nbsp;



</div> <div class="b"> <div> </div> </div> </div>
















<div class="dialog"> <div class="boxContent"> <div class="t"></div>






<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFD700" width="100%"><tbody><tr valign="top"><td valign="top">

&nbsp;&nbsp;<br><table class="tablemasterbleue" style="font-size:11px;" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr class="headerlist">
<td width="100" align="center">Prod #</td>
<td width="100" align="center">Manufacturer</td>
<td width="75" align="center">Qty</td>
<td width="35"></td>
<td width="35"></td>
<td width="">Description</td>
<td width="35"></td>
<td width="100" align="center">Price</td>
</tr>


<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr><tr class="headerlist"><td colspan="8">

<table width="100%" style="font-size:12px; font-weight:bold;" border="0">
<tbody><tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">HST</td>
<td width="25">

<div id="tps">

49.4
</div>



</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50"></td>
<td width="25">


<div id="tvq">





</div>


</td>
</tr>
<tr style="color:#FFFFFF">
<td colspan="3">&nbsp;</td>
<td width="50">TOTAL</td>
<td width="25">
<div id="total">
429.4
</div>
</td>
</tr>
</tbody></table>

</td></tr>

</tbody></table>






</td></tr></tbody></table>


<br><br>






</div> <div class="b"> <div> </div> </div> </div>

</td></tr>

<tr><td>


</td></tr>

<tr><td>
<form id="form1" name="form1" method="post" action="/sendorder-en.html">

<div class="dialog"> <div class="boxContent"> <div class="t"></div>


<table style="color:#FFFFFF" width="100%" border="0" cellpadding="3" cellspacing="5">


<tbody><tr>
<td colspan="2" align="right">




<br><b>This order does not apply to a national account<b><br><input type="hidden" value="n" name="clinat" id="clinat">






</b></b></td>
</tr>


<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="50%"><b>Delivery Instruction: </b></td>
<td width="50%"><input type="hidden" value="y" name="basketsend" id="basketsend"><input type="hidden" value="y" name="type" id="type"></td>
</tr>
<tr>
<td rowspan="3" align="left" valign="top"><label>
<input name="instruction" type="text" id="instruction" value="" maxlength="68" size="50">
</label></td>
<td align="right">



<table cellpadding="3" cellspacing="3" border="0">
<tbody><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio1" checked="checked">Next delivery
<input type="radio" name="radio" id="radio" value="radio2">Morning
<input type="radio" name="radio" id="radio" value="radio3">Afternoon
</td>
</tr>

<tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio4">Tomorrow Morning
<input type="radio" name="radio" id="radio" value="radio5">Tomorrow Afternoon
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio8">Standard Delivery
<input type="radio" name="radio" id="radio" value="radio9">Urgent delivery
</td>
</tr><tr>
<td align="right">
<input type="radio" name="radio" id="radio" value="radio6">Pick Up
<input type="radio" name="radio" id="radio" value="radio7">See Special Instruction
</td>
</tr>
</tbody></table>



</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">Purchase Order :
<label>
<input type="text" name="boncom" id="boncom" maxlength="10">
</label></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right"><input class="normal" width="300px" type="submit" name="buttonsend" id="buttonsend" value="Send" onclick="javascript:this.disabled=true;form1.submit();"></td>
</tr>
</tbody></table>
</div> <div class="b"> <div> </div> </div> </div> </form>
</td></tr></tbody></table>
<br>

<script>
$(document).ready(function() {
/*$('a#first').imgPreview();*/
$('a#first').imgPreview({
imgCSS: { width: 250 }
}); });

</script> <br></td>
<td width="15">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody></table>
<table width="960" cellspacing="0" cellpadding="0" class="tablemasterbleueborder" border="3">

<tbody><tr>
<td height="36" align="center" valign="middle" bgcolor="#ffffff">

<table width="100%">
<tbody><tr>
<td align="center">
<a href="http://www.inosoft.ca/english/index.htm"> <img src="images/inosoft-en.jpg" width="125" height="35" alt="InoSoft"> </a>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<br>
<center>
<a href="exit-en.html" style="color:#000">Exit</a>
</center>
<br></td>
</tr>
</tbody></table>
<div id="imgPreviewContainer" style="display: none;"><img style="width: 250px;"></div></body></html>


Here is also screenshot of inspect element : https://i.imgur.com/o59X5wA.png
enter image description here



So I'm going to use the xpath or do I need another solution?



thank you in advance.






/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]





/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[2]/td[1]






c# html xpath google-chrome-devtools html-agility-pack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 17:18









Ňuf

4,95421322




4,95421322










asked Nov 22 '18 at 10:04









BazSaraaBazSaraa

12




12













  • Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

    – Corion
    Nov 22 '18 at 12:24











  • the page use HTML

    – BazSaraa
    Nov 22 '18 at 12:37











  • <td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

    – BazSaraa
    Nov 22 '18 at 12:37











  • Please edit your question and add the additional data there.

    – Corion
    Nov 22 '18 at 12:39











  • i want to add screenshots but they dosen't allow.

    – BazSaraa
    Nov 22 '18 at 12:40



















  • Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

    – Corion
    Nov 22 '18 at 12:24











  • the page use HTML

    – BazSaraa
    Nov 22 '18 at 12:37











  • <td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

    – BazSaraa
    Nov 22 '18 at 12:37











  • Please edit your question and add the additional data there.

    – Corion
    Nov 22 '18 at 12:39











  • i want to add screenshots but they dosen't allow.

    – BazSaraa
    Nov 22 '18 at 12:40

















Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

– Corion
Nov 22 '18 at 12:24





Does the page you're scraping use Javascript or is the HTML ready to parse? Please reduce your XPath expression and your HTML to something postable and post that. Without seeing the HTML (and Minimal, Complete, and Verifiable example), we can't reproduce your situation and then we can not really help you.

– Corion
Nov 22 '18 at 12:24













the page use HTML

– BazSaraa
Nov 22 '18 at 12:37





the page use HTML

– BazSaraa
Nov 22 '18 at 12:37













<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

– BazSaraa
Nov 22 '18 at 12:37





<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>

– BazSaraa
Nov 22 '18 at 12:37













Please edit your question and add the additional data there.

– Corion
Nov 22 '18 at 12:39





Please edit your question and add the additional data there.

– Corion
Nov 22 '18 at 12:39













i want to add screenshots but they dosen't allow.

– BazSaraa
Nov 22 '18 at 12:40





i want to add screenshots but they dosen't allow.

– BazSaraa
Nov 22 '18 at 12:40












2 Answers
2






active

oldest

votes


















0














Actual problem is that XPath queries like //tbody/tr[" + i + "]/td[5]/span returns null, because there is no corresponding span HTML element and so .InnerText crashes with NullReferenceException. Also indexes of td elements (like td[5]) seems to be wrong. Correct XPath is //tbody/tr[" + i + "]/td[6]. But you can rewrite your code to make it much better.



Because you want to iterate through multiple product nodes, it is better to use doc.DocumentNode.SelectNodes() that returns collection of all matching nodes (products) instead of doc.DocumentNode.SelectSingleNode(). Each selected product node looks similar to this:



<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr>


With this node already selected, you don't need to execute whole complicated XPath query like /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1] again to gather desired pieces of information. Execute XPath query only agains HTML node selected above, e.g. node.SelectSingleNode("td[1]"), which is not only much shorter and readable, but also more efficient. Whole code may look like this:



HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

foreach(var node in doc.DocumentNode
.SelectNodes("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr")
.Skip(1)/*Skip first row containing headers*/)
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


Because obtained strings may contain excessive HTML entities and spaces like "&nbsp; &nbsp; 00959", you may need to remove them:



// Convert string like "&nbsp;  &nbsp; 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();





share|improve this answer
























  • Your code it's very practical and I will use it thank you so much for your help. :)

    – BazSaraa
    Nov 22 '18 at 17:41











  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

    – BazSaraa
    Nov 23 '18 at 11:38













  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 23 '18 at 12:20











  • This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

    – Ňuf
    Nov 23 '18 at 12:42



















0














tablemasterbleue is a class not id and because no method GetElementsByClassName extract get page source with WebBrowser1.DocumentText then loop rows or tr.



the following xpath will select rows in table class tablemasterbleue but skip if has class headerlist which exist in the top and bottom.



doc.LoadHtml(WebBrowser1.DocumentText);

foreach (var node in doc.DocumentNode
.SelectNodes("//table[@class='tablemasterbleue']/tbody/tr[not(contains(@class, 'headerlist'))]"))
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}





share|improve this answer


























  • unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 26 '18 at 13:28













  • do you now what variable that null?

    – ewwink
    Nov 26 '18 at 13:58











  • Yes source parameter I think.

    – BazSaraa
    Nov 26 '18 at 15:43












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428410%2fwhen-i-use-xpath-to-extract-data-it-dosent-give-any-response-in-the-messagebox%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Actual problem is that XPath queries like //tbody/tr[" + i + "]/td[5]/span returns null, because there is no corresponding span HTML element and so .InnerText crashes with NullReferenceException. Also indexes of td elements (like td[5]) seems to be wrong. Correct XPath is //tbody/tr[" + i + "]/td[6]. But you can rewrite your code to make it much better.



Because you want to iterate through multiple product nodes, it is better to use doc.DocumentNode.SelectNodes() that returns collection of all matching nodes (products) instead of doc.DocumentNode.SelectSingleNode(). Each selected product node looks similar to this:



<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr>


With this node already selected, you don't need to execute whole complicated XPath query like /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1] again to gather desired pieces of information. Execute XPath query only agains HTML node selected above, e.g. node.SelectSingleNode("td[1]"), which is not only much shorter and readable, but also more efficient. Whole code may look like this:



HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

foreach(var node in doc.DocumentNode
.SelectNodes("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr")
.Skip(1)/*Skip first row containing headers*/)
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


Because obtained strings may contain excessive HTML entities and spaces like "&nbsp; &nbsp; 00959", you may need to remove them:



// Convert string like "&nbsp;  &nbsp; 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();





share|improve this answer
























  • Your code it's very practical and I will use it thank you so much for your help. :)

    – BazSaraa
    Nov 22 '18 at 17:41











  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

    – BazSaraa
    Nov 23 '18 at 11:38













  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 23 '18 at 12:20











  • This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

    – Ňuf
    Nov 23 '18 at 12:42
















0














Actual problem is that XPath queries like //tbody/tr[" + i + "]/td[5]/span returns null, because there is no corresponding span HTML element and so .InnerText crashes with NullReferenceException. Also indexes of td elements (like td[5]) seems to be wrong. Correct XPath is //tbody/tr[" + i + "]/td[6]. But you can rewrite your code to make it much better.



Because you want to iterate through multiple product nodes, it is better to use doc.DocumentNode.SelectNodes() that returns collection of all matching nodes (products) instead of doc.DocumentNode.SelectSingleNode(). Each selected product node looks similar to this:



<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr>


With this node already selected, you don't need to execute whole complicated XPath query like /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1] again to gather desired pieces of information. Execute XPath query only agains HTML node selected above, e.g. node.SelectSingleNode("td[1]"), which is not only much shorter and readable, but also more efficient. Whole code may look like this:



HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

foreach(var node in doc.DocumentNode
.SelectNodes("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr")
.Skip(1)/*Skip first row containing headers*/)
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


Because obtained strings may contain excessive HTML entities and spaces like "&nbsp; &nbsp; 00959", you may need to remove them:



// Convert string like "&nbsp;  &nbsp; 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();





share|improve this answer
























  • Your code it's very practical and I will use it thank you so much for your help. :)

    – BazSaraa
    Nov 22 '18 at 17:41











  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

    – BazSaraa
    Nov 23 '18 at 11:38













  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 23 '18 at 12:20











  • This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

    – Ňuf
    Nov 23 '18 at 12:42














0












0








0







Actual problem is that XPath queries like //tbody/tr[" + i + "]/td[5]/span returns null, because there is no corresponding span HTML element and so .InnerText crashes with NullReferenceException. Also indexes of td elements (like td[5]) seems to be wrong. Correct XPath is //tbody/tr[" + i + "]/td[6]. But you can rewrite your code to make it much better.



Because you want to iterate through multiple product nodes, it is better to use doc.DocumentNode.SelectNodes() that returns collection of all matching nodes (products) instead of doc.DocumentNode.SelectSingleNode(). Each selected product node looks similar to this:



<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr>


With this node already selected, you don't need to execute whole complicated XPath query like /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1] again to gather desired pieces of information. Execute XPath query only agains HTML node selected above, e.g. node.SelectSingleNode("td[1]"), which is not only much shorter and readable, but also more efficient. Whole code may look like this:



HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

foreach(var node in doc.DocumentNode
.SelectNodes("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr")
.Skip(1)/*Skip first row containing headers*/)
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


Because obtained strings may contain excessive HTML entities and spaces like "&nbsp; &nbsp; 00959", you may need to remove them:



// Convert string like "&nbsp;  &nbsp; 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();





share|improve this answer













Actual problem is that XPath queries like //tbody/tr[" + i + "]/td[5]/span returns null, because there is no corresponding span HTML element and so .InnerText crashes with NullReferenceException. Also indexes of td elements (like td[5]) seems to be wrong. Correct XPath is //tbody/tr[" + i + "]/td[6]. But you can rewrite your code to make it much better.



Because you want to iterate through multiple product nodes, it is better to use doc.DocumentNode.SelectNodes() that returns collection of all matching nodes (products) instead of doc.DocumentNode.SelectSingleNode(). Each selected product node looks similar to this:



<tr style="padding: 0px 10px 0px 10px; color:#000000; height:40px;" bgcolor="#EDEDED">
<td align="left" width="125">&nbsp; <a href="/?ordernow=y&amp;rem=order&amp;prod=1"><img src="http://www.provincialtire.net/images/redcross.png"></a> &nbsp; 00959</td>
<td align="center"><img title="" width="75" height="27" src="http://www.provincialtire.net/provt/images/plugins/logo/UNIR.gif"></td>
<td align="center"> 4 </td>
<td align="left">-</td><td> <img width="30" src="http://www.provincialtire.net/provt/images/plugins/type/W.png"> </td>
<td align="left">&nbsp;&nbsp;205/60R16 Tiger Paw Ice &amp; Snow 3 </td>
<td align="right"><div id="each1"><b></b></div></td><td style="background-image:url(/images/special.gif); background-repeat:no-repeat; background-position:top" align="center"><b>95.00</b></td>
</tr>


With this node already selected, you don't need to execute whole complicated XPath query like /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr[" + i + "]/td[1] again to gather desired pieces of information. Execute XPath query only agains HTML node selected above, e.g. node.SelectSingleNode("td[1]"), which is not only much shorter and readable, but also more efficient. Whole code may look like this:



HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webBrowser1.Document.GetElementById("tablemasterbleue").InnerHtml);

foreach(var node in doc.DocumentNode
.SelectNodes("/html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr")
.Skip(1)/*Skip first row containing headers*/)
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}


Because obtained strings may contain excessive HTML entities and spaces like "&nbsp; &nbsp; 00959", you may need to remove them:



// Convert string like "&nbsp;  &nbsp; 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 17:09









ŇufŇuf

4,95421322




4,95421322













  • Your code it's very practical and I will use it thank you so much for your help. :)

    – BazSaraa
    Nov 22 '18 at 17:41











  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

    – BazSaraa
    Nov 23 '18 at 11:38













  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 23 '18 at 12:20











  • This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

    – Ňuf
    Nov 23 '18 at 12:42



















  • Your code it's very practical and I will use it thank you so much for your help. :)

    – BazSaraa
    Nov 22 '18 at 17:41











  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

    – BazSaraa
    Nov 23 '18 at 11:38













  • Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 23 '18 at 12:20











  • This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

    – Ňuf
    Nov 23 '18 at 12:42

















Your code it's very practical and I will use it thank you so much for your help. :)

– BazSaraa
Nov 22 '18 at 17:41





Your code it's very practical and I will use it thank you so much for your help. :)

– BazSaraa
Nov 22 '18 at 17:41













Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

– BazSaraa
Nov 23 '18 at 11:38







Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'La valeur ne peut pas être null. Nom du paramètre : source'

– BazSaraa
Nov 23 '18 at 11:38















Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

– BazSaraa
Nov 23 '18 at 12:20





Hello I just wanna ask you when I execute my code in foreach line it gives me this message error : System.ArgumentNullException: 'The value can not be null. Parameter name: source'

– BazSaraa
Nov 23 '18 at 12:20













This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

– Ňuf
Nov 23 '18 at 12:42





This means that there is no HTML element that matches requested XPath /html/body/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table[2]/tbody/tr[1]/td/div[2]/div[1]/table/tbody/tr/td/table/tbody/tr. In HTML document you provided there are 3 matching nodes, but if you tried with another HTML document, there can be no such element and in that case SelectNodes() returns null. If you cannot guarantee that at least 1 matching HTML element exists, you'll need to add null-check to deal with such condition.

– Ňuf
Nov 23 '18 at 12:42













0














tablemasterbleue is a class not id and because no method GetElementsByClassName extract get page source with WebBrowser1.DocumentText then loop rows or tr.



the following xpath will select rows in table class tablemasterbleue but skip if has class headerlist which exist in the top and bottom.



doc.LoadHtml(WebBrowser1.DocumentText);

foreach (var node in doc.DocumentNode
.SelectNodes("//table[@class='tablemasterbleue']/tbody/tr[not(contains(@class, 'headerlist'))]"))
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}





share|improve this answer


























  • unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 26 '18 at 13:28













  • do you now what variable that null?

    – ewwink
    Nov 26 '18 at 13:58











  • Yes source parameter I think.

    – BazSaraa
    Nov 26 '18 at 15:43
















0














tablemasterbleue is a class not id and because no method GetElementsByClassName extract get page source with WebBrowser1.DocumentText then loop rows or tr.



the following xpath will select rows in table class tablemasterbleue but skip if has class headerlist which exist in the top and bottom.



doc.LoadHtml(WebBrowser1.DocumentText);

foreach (var node in doc.DocumentNode
.SelectNodes("//table[@class='tablemasterbleue']/tbody/tr[not(contains(@class, 'headerlist'))]"))
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}





share|improve this answer


























  • unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 26 '18 at 13:28













  • do you now what variable that null?

    – ewwink
    Nov 26 '18 at 13:58











  • Yes source parameter I think.

    – BazSaraa
    Nov 26 '18 at 15:43














0












0








0







tablemasterbleue is a class not id and because no method GetElementsByClassName extract get page source with WebBrowser1.DocumentText then loop rows or tr.



the following xpath will select rows in table class tablemasterbleue but skip if has class headerlist which exist in the top and bottom.



doc.LoadHtml(WebBrowser1.DocumentText);

foreach (var node in doc.DocumentNode
.SelectNodes("//table[@class='tablemasterbleue']/tbody/tr[not(contains(@class, 'headerlist'))]"))
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}





share|improve this answer















tablemasterbleue is a class not id and because no method GetElementsByClassName extract get page source with WebBrowser1.DocumentText then loop rows or tr.



the following xpath will select rows in table class tablemasterbleue but skip if has class headerlist which exist in the top and bottom.



doc.LoadHtml(WebBrowser1.DocumentText);

foreach (var node in doc.DocumentNode
.SelectNodes("//table[@class='tablemasterbleue']/tbody/tr[not(contains(@class, 'headerlist'))]"))
{
string Code_de_ligne = "";
string Numero_de_produit = node.SelectSingleNode("td[1]").InnerText;
string Desc_prod = node.SelectSingleNode("td[6]").InnerText;
string Prix_coutânt = node.SelectSingleNode("td[8]").InnerText;
string Prix_de_vente = "";
string Qte = node.SelectSingleNode("td[3]").InnerText;

MessageBox.Show(Code_de_ligne + "|" + Numero_de_produit + "|" + Desc_prod + " | " + Prix_coutânt + "|" + Prix_de_vente + "|" + Qte);
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 13:31

























answered Nov 24 '18 at 7:31









ewwinkewwink

12.3k22441




12.3k22441













  • unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 26 '18 at 13:28













  • do you now what variable that null?

    – ewwink
    Nov 26 '18 at 13:58











  • Yes source parameter I think.

    – BazSaraa
    Nov 26 '18 at 15:43



















  • unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

    – BazSaraa
    Nov 26 '18 at 13:28













  • do you now what variable that null?

    – ewwink
    Nov 26 '18 at 13:58











  • Yes source parameter I think.

    – BazSaraa
    Nov 26 '18 at 15:43

















unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

– BazSaraa
Nov 26 '18 at 13:28







unfortunately it doesn't work for me, it still the same error System.ArgumentNullException: 'The value can not be null. Parameter name: source'

– BazSaraa
Nov 26 '18 at 13:28















do you now what variable that null?

– ewwink
Nov 26 '18 at 13:58





do you now what variable that null?

– ewwink
Nov 26 '18 at 13:58













Yes source parameter I think.

– BazSaraa
Nov 26 '18 at 15:43





Yes source parameter I think.

– BazSaraa
Nov 26 '18 at 15:43


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428410%2fwhen-i-use-xpath-to-extract-data-it-dosent-give-any-response-in-the-messagebox%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to pass form data using jquery Ajax to insert data in database?

National Museum of Racing and Hall of Fame

Guess what letter conforming each word