I want to import a numerical value from
CodePudding user response:
In your situation, how about the following sample formula?
Sample formula:
=IMPORTXML(A1,"//div[@data-name='REG']//div[div[@class='stats_label']/text()='LDCP']/div[@class='stats_value']")
In this case, the URL of
https://dps.psx.com.pk/company/SYS
is put in the cell "A1".When you want to put the value to the cell "B2", please put
=IMPORTXML("https://dps.psx.com.pk/company/SYS","//div[@data-name='REG']//div[div[@class='stats_label']/text()='LDCP']/div[@class='stats_value']")
to the cell "B2".I thought that in this case, the following formula can be also used.
=IMPORTXML(A1,"//div[@data-name='REG']//div[@class='stats_value'][../div[@class='stats_label']/text()='LDCP']")
Result:
Note:
- The XPath of this sample formula is for your URL of
https://dps.psx.com.pk/company/SYS
. So, when you changed the URL, the XPath might not be able to be used. So please be careful about this.
CodePudding user response:
You can use
=REGEXEXTRACT(INDEX(IMPORTXML(A1,"//div[@data-name='REG']"),2,4),"LDCP(\d \.\d )")
assuming that =TRANSPOSE(IMPORTXML(A1,"//div[@data-name='REG']"))
will give you these informations
By index
I fetch the cell I need, then I apply a simple regexextract
formula.
This way you can easily retrieve other information.