Power Automate Exchange

Please login or click SIGN UP FOR FREE to create your FlowUG account to join this user group.
 View Only
  • 1.  XPath XML decoding

    Top Contributor
    Posted Feb 17, 2022 01:21 PM
    I'm trying to parse out an XML feed using xpath, but struggling to get the right path elements. I keep coming up with [] for the xpath outputs. Any ideas?

    The source 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-17T13:19:32Z</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-17T13:19:32Z</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>

    i've tried xpath of feed/entry/content and //content and //entry but all return []

    ------------------------------
    Sam Duval
    Data Quality Analyst
    Element Financial
    Indianapolis IN
    ------------------------------


  • 2.  RE: XPath XML decoding

    Posted 22 days ago
    Did you figure this out?  I am having a similar issue with xpath returning an empty array.  I have validate the xml and xpath expression with an online tester and I get the expected results.  In Power Automate I get [].

    ------------------------------
    Justin Kolterman
    ------------------------------



  • 3.  RE: XPath XML decoding

    Posted 22 days ago
    The issue is with the namespace(s) definition.... in your case:
    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">


    your xpath would need to look like this:
    xpath(xmlSource),'/*[name()="feed"]/*[name()="entry"]/*[name()="content"]'


    ------------------------------
    Justin Kolterman
    ------------------------------