Showing results for 
Search instead for 
Did you mean: 
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?



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="">
  <m:properties xmlns:m="">
    <d:Id m:type="Edm.Int32" xmlns:d="">8041</d:Id>
    <d:NEW_DATE m:type="Edm.DateTime" xmlns:d="">2022-02-16T00:00:00</d:NEW_DATE>
    <d:BC_1MONTH m:type="Edm.Double" xmlns:d="">0.03</d:BC_1MONTH>
    <d:BC_2MONTH m:type="Edm.Double" xmlns:d="">0.17</d:BC_2MONTH>
    <d:BC_3MONTH m:type="Edm.Double" xmlns:d="">0.38</d:BC_3MONTH>
    <d:BC_6MONTH m:type="Edm.Double" xmlns:d="">0.67</d:BC_6MONTH>
    <d:BC_1YEAR m:type="Edm.Double" xmlns:d="">1.09</d:BC_1YEAR>
    <d:BC_2YEAR m:type="Edm.Double" xmlns:d="">1.52</d:BC_2YEAR>
    <d:BC_3YEAR m:type="Edm.Double" xmlns:d="">1.75</d:BC_3YEAR>
    <d:BC_5YEAR m:type="Edm.Double" xmlns:d="">1.90</d:BC_5YEAR>
    <d:BC_7YEAR m:type="Edm.Double" xmlns:d="">2.00</d:BC_7YEAR>
    <d:BC_10YEAR m:type="Edm.Double" xmlns:d="">2.03</d:BC_10YEAR>
    <d:BC_20YEAR m:type="Edm.Double" xmlns:d="">2.39</d:BC_20YEAR>
    <d:BC_30YEAR m:type="Edm.Double" xmlns:d="">2.34</d:BC_30YEAR>
    <d:BC_30YEARDISPLAY m:type="Edm.Double" xmlns:d="">2.34</d:BC_30YEARDISPLAY>




Original XML

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xml:base="" xmlns:d="" xmlns:m="" xmlns=""> 
<title type="text">DailyTreasuryYieldCurveRateData</title>
<link rel="self" title="DailyTreasuryYieldCurveRateData" href="DailyTreasuryYieldCurveRateData"/>
<title type="text"></title>
<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="" />
<content type="application/xml">
<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>



Accepted Solutions
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()')



View solution in original post

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()')



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

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)