1

I am trying to retrieve and parse xml data from the following URL using

=IMPORTXML("https://monitoringapi.solaredge.com/site/894123/sensors?startDate=2020-10-01%2000:00:00&endDate=2020-10-06%2000:00:00&api_key=MGTH4B2W39EJ8O433GSMRNQHRY0WKF9C";"/siteSensors/data/telemetries/sensorsTelemetry")

or

=IMPORTXML("https://monitoringapi.solaredge.com/site/894123/sensors?startDate=2020-10-01%2000:00:00&endDate=2020-10-06%2000:00:00&api_key=MGTH4B2W39EJ8O433GSMRNQHRY0WKF9C","//date | //globalHorizontalIrradiance")

I keep on getting the error message 'Imported XML content cannot be parsed'.

I've checked the xpath in an online xpath tester and it returns data fine.

When i put the URL in a browser window I do indeed receive the XML (which curiously has a script element at the end....)

All help most gratefully appreciated,

Best regards /Colm

0

1 Answer 1

1

Add an extra &format=xml to your URL:

=IMPORTXML("https://monitoringapi.solaredge.com/site/894123/sensors?startDate=2020-10-01%2000:00:00&endDate=2020-10-06%2000:00:00&api_key=MGTH4B2W39EJ8O433GSMRNQHRY0WKF9C&format=xml";"//siteSensors/data/telemetries/sensorsTelemetry")

It looks like the API gives Google Sheets JSON data by default. According to the Solaredge API docs, you can specify the format as json, xml, or csv. (The docs say you want application/xml, but this didn't work for me.)

Sign up to request clarification or add additional context in comments.

2 Comments

Excellent ! Thank you for reading the docs better then I did.
@carbontracking Eh, I can't fault you for thinking that it returns XML data based on what you get when pasting it into the address bar. Probably some user-agent check on the site or something. Go figure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.