Scrape from XML/XML syntax

visu

New Member
Joined
Dec 22, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
With the risk of having this query rejected immediately - I've been using Google Sheets to scrape website information (but I think my question is ambigious to Excel and Sheets) - last prices of stocks - for a few years but have suddenly run in to issues.
I'm scraping using
Excel Formula:
=importxml("URL", "XPATH")

Here's an example of a webpage I'm scraping from
Novo Nordisk B A/S (NOVO B) aktie
Where the latest price is listed under "Senast" in the top left corner

The xpath i'm getting from Chrome's inspector tool is
//*[@id='main-content']/div/div[1]/div/div/div[1]/div[2]/div/div[1]/div[1]/div/span

However, this returns a matrix/array:
17:20:00 · Nasdaq Copenhagen
696,4
Where I'm only interested in getting "696,4"

So, to my question:
What is the syntax to retrieve only 696,4?

Thank you!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi, try this,
VBA Code:
=index(split(importxml("url", "xpath"),"|"),2,1)
 
Upvote 0
Solution

Forum statistics

Threads
1,216,085
Messages
6,128,732
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top