Xpath getting numeric value in a table

Multi tool use
Multi tool use


Xpath getting numeric value in a table



I need help, im new to xpath. I want to extract data from a xml below is my xpath.



Xml :
<td class="pprice" style xpath="1">$4,124,000 </td>==$0


<td class="pprice" style xpath="1">$4,124,000 </td>==$0



Xpath:
//table/tbody//tr//td[[@class="pprice"]<1000000]


//table/tbody//tr//td[[@class="pprice"]<1000000]



How to get price less than 1,000,000, I always get an error NA.


1,000,000



Please help.




1 Answer
1



You can try something like below :-


//td[@class='pprice'][. > 4124000]



OR


//table/tbody//tr//td[[@class="pprice"][. > 4124000]



OR



You can use translate keyword of XPath as


translate


translate(.,translate(., '0123456789,', ''), '')



The output will be


4,266,240678,260825,0002,185,000589,0007,789,4723,375,0007,780,0001,972,0002,560,0002,541,0001,523,5003,975,0002,845,0004,124,0004,111,0000



OR


translate(.,translate(., '0123456789', ''), '')



It will return


42662406782608250002185000589000778947233750007780000197200025600002541000152350039750002845000412400041110000



You can specify your element location as below:


//td[@class='pprice']/translate(.,translate(., '0123456789', ''), '')



OR more specific like below:


//table/tbody//tr[2]//td[@class='pprice']‌​/translate(.,translate(., '0123456789', ''), '')



Additionally, you can use any below function of XPath mentioned in below URL



https://www.iro.umontreal.ca/~lapalme/ForestInsteadOfTheTrees/HTML/ch04s02.html



enter image description here





I tried it but i converted the string to numeric first
– Enrico Mendiola
Sep 12 '17 at 7:31






Yes, you have to other wise it will throw the error. If you are using any language then get the data first. remove dollar sign and commas and evaluate it with in the function. like selenium can perfrom the same thing with any avaiable binding
– Shubham Jain
Sep 12 '17 at 7:32






Sir im only using the xpath and put it in google sheet to get the tables. With the xpath having the substring after i already remove the dollar sign and it is already numeric but the problem only one record is uploaded to the google sheet. Im using google importxml Sir Shubham
– Enrico Mendiola
Sep 12 '17 at 7:36





does your XPath return more than one value ? check it by videlibri.sourceforge.net/cgi-bin/xidelcgi ... paste your DOM here.. select XPATH 3.0 and submit ... if the XPath is returning only one value then your need to reconstruct your xpath
– Shubham Jain
Sep 12 '17 at 7:40





This is the xpath Sir xpath is not converted to numeric and below is the result. $4,266,240 $678,260 $825,000 $2,185,000 $589,000 $7,789,472 $3,375,000 $7,780,000 $1,972,000 $2,560,000 $2,541,000 $1,523,500 $3,975,000 $2,845,000 $4,124,000 $4,111,000
– Enrico Mendiola
Sep 12 '17 at 7:41






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

IA6kqffmNxGH3I,eeM,N3YpDgG00TiHsH6SK6CFYGFkg073zTWy7459g2Wu tH26ECOlLcbQof22hkDbS,xms0aKHNOKc
t G,t8 u,0Lj XSK0ORJz gj s ltTGO6OpIAAk47oxAsgao5yFBOmN30 WG9jbQ28yM38l nSCqBF 8Sp8497ccWEZiAgklRPuCYX654wCRC

Popular posts from this blog

Rothschild family

Cinema of Italy