I would like to import into Google Sheets the ECB official USD/EUR conversion rates from this link:
https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/usd.xml
But I can't figure out how to phrase the XPATH. I tried this for example:
=importxml("https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/usd.xml", "/CompactData/DataSet/Series/Obs/@TIME_PERIOD")
But I always get "import content is empty". Would appreciate any help, many thanks ahead!
Although I'm not sure whether I could correctly understand your expected values, how about the following formula?
=LET(VALUE_URL,"https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/usd.xml",BASE_XPATH,"//*[local-name()='Obs']/",{IMPORTXML(VALUE_URL, BASE_XPATH&"@TIME_PERIOD"),IMPORTXML(VALUE_URL, BASE_XPATH&"@OBS_VALUE")})
In this case, the XPath of each value is //*[local-name()='Obs']/@TIME_PERIOD
and //*[local-name()='Obs']/@OBS_VALUE
.
For example, when you want to retrieve the values of @TIME_PERIOD
, you can use the following formula.
=IMPORTXML("https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/usd.xml","//*[local-name()='Obs']/@TIME_PERIOD")