G. Jonathan
G. Jonathan

Reputation: 74

XPath use in online XML feed

I would like to use the following page: https://home.treasury.gov/resource-center/data-chart-center/interest-rates/pages/xml?data=daily_treasury_yield_curve&field_tdr_date_value_month=202502

My goal is to exploit its data in a google spreadsheet using the importXML function. I can see that the xml tags are a bit odd and does not translate well using Xpath.

Can someone help me or pointing me the right way to use XPATH with such an XML?

I used =IMPORTXML("https://home.treasury.gov/resource-center/data-chart-center/interest-rates/pages/xml?data=daily_treasury_yield_curve&field_tdr_date_value_month=202502", "//m:properties[@d:NEW_DATE='2025-02-14T00:00:00']")

Which normally should fetch all m:properties where the date value is the one filtered. Issue being that the function is always giving N/A back as an error.

The only thing I succeeded to get is by using //*. This indicates that the URL is valid but that there is an error with the XPATH.

//entry and //content does not work either as well as @* or node(). [https://stackoverflow.com/questions/63512048/having-trouble-finding-the-correct-xpath-or-xslt-to-properly-parse-this-xml-feed](I tried this) by specifying the full patch but no lock there.

Tried this solution but it does not provide any meaningful result. Specifying the local-name feed from the xml feed returns the same as just using /*.

I am still figuring out the solution to filter the xml feed and receive back the m:properties of the last entry from the list.

Ideally I would like to retrieve the content of <m:properties> from the first

Upvotes: 0

Views: 28

Answers (0)

Related Questions