Answered by:
Retrive the TD innertext value

Question
-
User2056512907 posted
hi,I have the below HTMl and i need to get the Available QTY value 10.000 as a result . Needs to do a xpath in c# for geting the result.I have tried the below xpath but i couldnt get the result. Any help is appreciated.
using HtmlAgilitypack;
HtmlNode node = doc.DocumentNode.SelectSingleNode("//td[b[. = 'Available Qty :']]/following-sibling::td");
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<link href="/public/vista/york.css" type="text/css" rel="stylesheet">
</head>
<form name="myform" method="post">
<input type="HIDDEN" name="PLANT" value="">
<input type="HIDDEN" name="session_id" value="ZiAlfPry4VkUj2*wTbMql***VISTA312111$-21~-19868108">
<input type="HIDDEN" name="user_id" value="vijay">
<table border="0" width="620">
<tr>
<td class="title" colspan="4">
Product Availability
</td>
</tr>
<tr>
<td class="text" colspan="4">
<img border="0" src="/public/bc/icons/s_b_info.gif">
Quantities reflect forecasted production within time periods displayed <br>
<img border="0" src="/public/bc/icons/s_b_info.gif">
For any questions or concerns regarding your product availability please contact your Customer Service Representative at 800-536-6112
</td>
</tr>
<tr class="text">
<td colspan="4">
</td>
</tr>
<tr class="text">
<td width="20%">
<b>Customer ID :</b>
</td>
<td width="30%">
0010015272
</td>
<td width="20%">
<b>Customer Name :</b>
</td>
<td width="30%">
AIR COND. UTILITIES.
</td>
</tr>
<tr class="text">
<td>
<b>Item Number :</b>
</td>
<td>
ND120C00C6AAA3
</td>
<td>
<b>Item Description :</b>
</td>
<td>
10T_EVAP_230/460-3-60_R410A_
</td>
</tr>
<tr class="text">
<td>
<b>Dimensions :</b>
</td>
<td>
L030:W056:H065 - IN
</td>
<td>
<b>Price Family :</b>
</td>
<td>
2720
</td>
</tr>
<tr class="text">
<td valign="top">
<b>Weight :</b>
</td>
<td valign="top">
562.000 (LB)
</td>
<td>
<b>UPC Code :</b>
</td>
<td>
883982733421
</td>
</tr>
<tr class="text">
<td valign="top">
<b>Ship From Plant :</b>
</td>
<td valign="top">
US UPG Norman
</td>
<td colspan="2" valign="top">
<table border="0">
<tr class="text">
<td class="tableCommon">
<b>Brand </b>
</td>
<td class="tableCommon">
<b>List Price </b>
</td>
<td class="tableCommon">
<b>Net Price </b>
</td>
<td class="tableCommon">
<b>Discount </b>
</td>
</tr>
<tr class="text">
<td>
YORK
</td>
<td align="right">
5330.00
</td>
<td align="right">
2132.00
</td>
<td align="right">
60.00-
</td>
</tr>
</table>
</td>
</tr>
<!--
<tr class="text">
<td colspan="4">
<b>Replenishment Lead Time :</b>
16
<b>Factory Working Days </b>
</td>
</tr>
-->
<!-- begin of changes for task 3536 akumars11 16oct2007 -->
<!-- <td colspan="2"></td> -->
<tr class="text">
<td>
<b>Min. Order Quantity :</b>
</td>
<td>
0.000
</td>
<!-- begin of changes for task 3536 akumars11 16oct2007 -->
<tr class="text">
<td>
<!-- Begin of changes for SM 4000008069 (Change the name balance on hand to available qty) -->
<font size='3'> <b>Available Qty :</b> </font>
<!-- Insertion for SM 4000008069-->
<!-- End of insertion for SM 4000008069 -->
</td>
<td>
<font size='3'> 10.000 </font>
<!-- End of insertion for SM 4000007790 -->
</td>
</tr>
<!-- (Add current lead time and delivery date) -->
<!--insertion for SM 4000007790 -->
<tr class="text">
<td>
<font size='3'> <b>Current Lead Time :</b> </font>
</td>
<td>
<font size='3'> 26 Days </font>
</td>
<!-- Display the traffic light based on standard time and current lead time difference) -->
<td>
<img src="flash_red.gif" border="0" width="70" height="80">
</td>
</tr>
<tr class="text">
<td>
<font size='3'> <b>Est. Delivery Date :</b> </font>
</td>
<td>
<font size='3'> 2018/03/17 </font>
</td>
</tr>
<!-- Insertion for SM 4000007790-->
<!-- End of insertion for SM 4000008069 -->
<tr class="text">
<td>
<font size='3'><b>ABC indicator:</b></font>
<!-- End of Insertion for SM 4000007790-->
</td>
<td>
<font size='3'>A</font> <!-- Font added for SM 4000007790 -->
<!-- End of Insertion for SM 4000007790-->
</td>
<!-- Begin of changes for SM 4000007790 -->
</tr>
<tr>
<td class="text" colspan="4">
<font color='red'>*If Requested Delivery Date is earlier than Est. Delivery Date contact your Order Services Account Manager for confirmation. </font>
</td>
</tr>
<tr>
<td class="text" colspan="4">
<font color='red'>*Deliveries requested less than 15 days are subject to standard freight policies and Lead Time surcharges.</font>
</td>
</tr>
<!-- End of changes for SM 4000007790-->
<!-- begin of changes for SM 4000004032 -->
<!--Begin of insertion for SM 4000007790-->
<tr>
<td>
<table border="2">
<!--Insertion for SM 4000007790-->
<tr class="text">
<td class="tableCommon">
<b>ABC indicator</b>
</td>
<td class="tableCommon">
<b>Description </b>
</td>
<td class="tableCommon">
<b>Standard Lead Time </b>
<!-- End of changes for SM 4000007790-->
</td>
</tr>
<tr class="text">
<td>
A
</td>
<td align="left">
Make to Stock
</td>
<td align="left">
15
</td>
</tr>
<tr class="text">
<td>
B
</td>
<td align="left">
Assemble to Order
</td>
<td align="left">
30
</td>
</tr>
<tr class="text">
<td>
C
</td>
<td align="left">
Make to Order
</td>
<td align="left">
45
</td>
</tr>
<tr class="text">
<td>
D
</td>
<td align="left">
Obsolete, Discontinued
</td>
<td align="left">
15
</td>
</tr>
<tr class="text">
<td>
P
</td>
<td align="left">
Phased Out, Availability limited to current stock
</td>
<td align="left">
15
</td>
</tr>
<tr class="text">
<td>
T
</td>
<td align="left">
Coated Coil
</td>
<td align="left">
45
</td>
</tr>
<tr class="text">
<td>
V
</td>
<td align="left">
Vendor Direct ship
</td>
<td align="left">
45
</td>
</tr>
</table>
</td>
<!-- end of changes for SM 4000004032 -->
</tr>
<!--
<tr class="text">
<td colspan="4">
</td>
</tr>
<tr class="text">
<td colspan="4">
<B>Summary </B>
<INPUT id=button2 type=submit value="US UPG Norman" name="onInputProcessing(1001)">
<INPUT id=button2 type=submit value="US UPG Wichita" name="onInputProcessing(1002)">
<INPUT id=button2 type=submit value="US UPG Source 1" name="onInputProcessing(1003)">
<INPUT id=button2 type=submit value="US VRF Line of Business" name="onInputProcessing(1011)">
<INPUT id=button2 type=submit value="Small Tonnage Chillers" name="onInputProcessing(1012)">
<INPUT id=button2 type=submit value="" name="onInputProcessing(0165)">
</td>
</tr>
-->
<!-- Begin of comment for SM 4000008069 -->
<!-- Insertion for SM 4000007790 -->
<!-- End of comment for SM 4000008069 -->
<tr class="text">
<td colspan="4">
<hr>
</td>
</tr>
<tr>
<td class="text">
<b>Item Number </b>
</td>
<td class="text">
<input maxlength="18" size="18" name="txtitemnumber" value="ND120C00C6AAA3">
</td>
<td colspan="2" class="text">
<input id="button4" type="submit" value=" Download to Excel " name="onInputProcessing(submit)">
<input id="button4" type="submit" value="Search " name="onInputProcessing(search)">
</td>
</tr>
<tr>
<td colspan="3" class="text" align="center">
<input id="button1" type="submit" value="Previous - ND120C00C5AZZ3" name="onInputProcessing(prev)">
<input id="button4" type="submit" value="Next - ND120C00C6AZZ3" name="onInputProcessing(next)">
</td>
<td></td>
</tr>
<tr class="TEXT">
<td class="text" colspan="4">
<br>
<input id="button3" type="submit" value="Back " name="onInputProcessing(back)">
</td>
</tr>
<tr class="text">
<td class="smallstatementtext" colspan="4" align="right">
100
</td>
</tr>
</tr></table>
<input type="hidden" name="pl" value="1001;1002;1003;1011;1012;0165">
<input type="hidden" name="slsorg" value="US15">
<input type="hidden" name="txtqtyreq" value="999999">
<input type="hidden" name="nxtMdl" value="ND120C00C6AZZ3">
<input type="hidden" name="prvMdl" value="ND120C00C5AZZ3">
</form>
</html>Thanks
vj
Monday, February 19, 2018 10:55 PM
Answers
-
User1400794712 posted
Hi elegantkvc,
According to your code:
1.There is a 'font' tag between the 'td' and 'b' tags. Please add it to the code:
var node = doc.DocumentNode.SelectSingleNode("//td[font[b[. = 'Available Qty :']]]/following-sibling::td[font]");
2.When we use the content inside 'b' to get the specific td, the content should be complete. In the Html code, there are much white space between 'Available Qty' and ':'. We should keep the same amount of it in SelectSingleNode().
<b>Available Qty :</b>
var node = doc.DocumentNode.SelectSingleNode("//td[font[b[. = 'Available Qty :']]]/following-sibling::td[font]");
//The red part should be the same.Then when we use innerText, it will catch '\r\n' and a lot of white space, we should remove them.
node = node.Replace("\r", "").Replace("\n", "").Replace(" ", "");
Best Regards,
Daisy
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 2:20 AM
All replies
-
User1400794712 posted
Hi elegantkvc,
According to your code:
1.There is a 'font' tag between the 'td' and 'b' tags. Please add it to the code:
var node = doc.DocumentNode.SelectSingleNode("//td[font[b[. = 'Available Qty :']]]/following-sibling::td[font]");
2.When we use the content inside 'b' to get the specific td, the content should be complete. In the Html code, there are much white space between 'Available Qty' and ':'. We should keep the same amount of it in SelectSingleNode().
<b>Available Qty :</b>
var node = doc.DocumentNode.SelectSingleNode("//td[font[b[. = 'Available Qty :']]]/following-sibling::td[font]");
//The red part should be the same.Then when we use innerText, it will catch '\r\n' and a lot of white space, we should remove them.
node = node.Replace("\r", "").Replace("\n", "").Replace(" ", "");
Best Regards,
Daisy
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 2:20 AM -
User2056512907 posted
Works Perfect. Thanks Daisy
Tuesday, February 20, 2018 4:03 AM