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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi, try this,
VBA Code:
=index(split(importxml("url", "xpath"),"|"),2,1)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,367
Messages
6,171,669
Members
452,416
Latest member
johnog

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