While I am successful in getting (US) PMMS 30Y Fixed Mortgage Rates via XPATH, I am not as successful in getting the (US) Federal Curve Yields. What's different about these XML data sets that makes one work and not the other?
I have tried many variations and the only variation that works with this data set is using some series of */*/*/*
with an array qualifier [12]
.
The total count(*//)
of elements in this data set is 180.
I am using Google Sheets IMPORTXML(url,xpath) to perform this action.
THIS WORKS
=IMPORTXML("https://www.treasury.gov/resource-center/data-chart-center/interest-rates/pages/XmlView.aspx?data=yield","*/*/*/*/*[12]")
THIS DOES NOT
=IMPORTXML("https://www.treasury.gov/resource-center/data-chart-center/interest-rates/pages/XmlView.aspx?data=yield","*//d:BC_10YEAR")
NOR ANY OF THESE
*//*@d:BC_10YEAR
*//@d:BC_10YEAR
*//d:BC_10YEAR[1]
*//m:properties[@d:BC_10YEAR]
*//*m:properties[@d:BC_10YEAR]
And many other variations -- I think I have tried them all, but OBVIOUSLY something is eluding me.
The ideal result is to specifically get the latest BC_10YEAR which is as of this posting and according to the data set (2019-04-09T20:36:32Z) is 2.49.
<d:BC_10YEAR m:type="Edm.Double">2.49</d:BC_10YEAR>
DATA SETS ENCODED URLS
US TREASURY:
https://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData?$filter=month(NEW_DATE)%20eq%204%20and%20year(NEW_DATE)%20eq%202019
FREDDIE MAC
http://www.freddiemac.com/pmms/pmmsthin.html
With XPATH Query of:
http://www.freddiemac.com/pmms/pmmsthin.html IMPORTXML(url,xpath)
==========================================================================
XPATH //th[contains(text(),"30YR")]//..//td[1] 4.08 <== 30YR FMR
XPATH //th[contains(text(),"30YR")]//..//td[2] 0.5 <== 30YR Fees & Points