cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
srduval
Kudo Collector
Kudo Collector

Trying to Parse XML from US Treasury

I have this xml from the us treasury that I am trying to parse out via xpath. I've tried numerous iterations of xpath values, and they all return the empty brackets. []

 

I tried using this as the xpath expression and it almost works, but how do I now get down to the "d" elements to extract their values?

Xpath:

xpath(xml(outputs('Compose_3')),'/*[local-name()=''feed'']/*[local-name()=''entry'']/*[local-name()=''content'']')


I tried adding the following to the end and they didn't work. 

1. /*[local-name()=''m:properties'']

2. /*[local-name()=''m:''] 

output converted to a string

 

 

<content type="application/xml" xmlns="http://www.w3.org/2005/Atom">
  <m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <d:Id m:type="Edm.Int32" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">8041</d:Id>
    <d:NEW_DATE m:type="Edm.DateTime" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2022-02-16T00:00:00</d:NEW_DATE>
    <d:BC_1MONTH m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">0.03</d:BC_1MONTH>
    <d:BC_2MONTH m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">0.17</d:BC_2MONTH>
    <d:BC_3MONTH m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">0.38</d:BC_3MONTH>
    <d:BC_6MONTH m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">0.67</d:BC_6MONTH>
    <d:BC_1YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">1.09</d:BC_1YEAR>
    <d:BC_2YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">1.52</d:BC_2YEAR>
    <d:BC_3YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">1.75</d:BC_3YEAR>
    <d:BC_5YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">1.90</d:BC_5YEAR>
    <d:BC_7YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2.00</d:BC_7YEAR>
    <d:BC_10YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2.03</d:BC_10YEAR>
    <d:BC_20YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2.39</d:BC_20YEAR>
    <d:BC_30YEAR m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2.34</d:BC_30YEAR>
    <d:BC_30YEARDISPLAY m:type="Edm.Double" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2.34</d:BC_30YEARDISPLAY>
  </m:properties>
</content>

 

 

 

Original XML

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xml:base="https://home.treasury.gov/resource-center/data-chart-center/interest-rates/pages/xml" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> 
<title type="text">DailyTreasuryYieldCurveRateData</title>
<id>https://home.treasury.gov/resource-center/data-chart-center/interest-rates/pages/xml-item?data=daily_treasury_yield_curve</id>
<updated>2022-02-18T06:40:37Z</updated>
<link rel="self" title="DailyTreasuryYieldCurveRateData" href="DailyTreasuryYieldCurveRateData"/>
<entry>
<id>https://home.treasury.gov/resource-center/data-chart-center/interest-rates/pages/xml-item?data=daily_treasury_yield_curve&amp;id=8041</id>
<title type="text"></title>
<updated>2022-02-18T06:40:37Z</updated>
<author><name /></author>
<link rel="edit" title="DailyTreasuryYieldCurveRateDatum" href="/resource-center/data-chart-center/interest-rates/pages/xml-item?data=daily_treasury_yield_curve&amp;id=8041" />
<category term="TreasuryDataWarehouseModel.DailyTreasuryYieldCurveRateDatum" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">8041</d:Id>
<d:NEW_DATE m:type="Edm.DateTime">2022-02-16T00:00:00</d:NEW_DATE>
<d:BC_1MONTH m:type="Edm.Double">0.03</d:BC_1MONTH>
<d:BC_2MONTH m:type="Edm.Double">0.17</d:BC_2MONTH>
<d:BC_3MONTH m:type="Edm.Double">0.38</d:BC_3MONTH>
<d:BC_6MONTH m:type="Edm.Double">0.67</d:BC_6MONTH>
<d:BC_1YEAR m:type="Edm.Double">1.09</d:BC_1YEAR>
<d:BC_2YEAR m:type="Edm.Double">1.52</d:BC_2YEAR>
<d:BC_3YEAR m:type="Edm.Double">1.75</d:BC_3YEAR>
<d:BC_5YEAR m:type="Edm.Double">1.90</d:BC_5YEAR>
<d:BC_7YEAR m:type="Edm.Double">2.00</d:BC_7YEAR>
<d:BC_10YEAR m:type="Edm.Double">2.03</d:BC_10YEAR>
<d:BC_20YEAR m:type="Edm.Double">2.39</d:BC_20YEAR>
<d:BC_30YEAR m:type="Edm.Double">2.34</d:BC_30YEAR>
<d:BC_30YEARDISPLAY m:type="Edm.Double">2.34</d:BC_30YEARDISPLAY>
</m:properties>
</content>
</entry>
</feed>

 

1 ACCEPTED SOLUTION

Accepted Solutions
ManishJain
Solution Sage
Solution Sage

Hi @srduval ,

 

Use the following expressions if you are intending to extract text out of each node in "d" :

 

xpath(xml(outputs('Compose')), '//*[local-name()="properties"]/*[local-name()]/text()')

 

Thanks

View solution in original post

2 REPLIES 2
ManishJain
Solution Sage
Solution Sage

Hi @srduval ,

 

Use the following expressions if you are intending to extract text out of each node in "d" :

 

xpath(xml(outputs('Compose')), '//*[local-name()="properties"]/*[local-name()]/text()')

 

Thanks

srduval
Kudo Collector
Kudo Collector

I was able to update it to work with what you provided thank you! Follow-up question, is there a way to include the attribute name "BC_10YEAR" from the element tag <d:BC_10YEAR" m:type="Edm.Double">

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,790)