cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meneghino
Level 10

Having trouble with xPath, please help

I am having trouble parsing the following xml file with xpath:

http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

 

What would be the correct expression to obtain the 'time' attribute?

 

I have tried this after an HTTP call:

 

xpath(xml(body('HTTP')),'string(gesmes:Envelope/Cube/Cube/@time)')

 

 

However, I got the following error:

The template language function 'xpath' parameters are invalid: the 'xpath' parameter must be a supported, well formed XPath expression. Please see https://aka.ms/logicexpressions#xpath for usage details.

 

I had a look at the documentation but it did not help.

 

Any help most welcome, picture of the flow is here:

__.JPG

 

Maybe @yoshihirok or @v-micsh-msft can help with this? Please?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Having trouble with xPath, please help

Hi @Meneghino,

 

Take a try with the expression below:

xpath(xml(body('Http')), 'string(//@time)')

Image reference:

27.PNG

Results as below:

28.PNG

 

For the Xpath expression, check:

XPath Examples

 

I also tested with the Xpath node, but havn't figure out the structure of the XML file used here.

Specifying the Xpath with node will always result in error. (need more testing, : )

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: Having trouble with xPath, please help

Hi @Meneghino,

 

Take a try with the expression below:

xpath(xml(body('Http')), 'string(//@time)')

Image reference:

27.PNG

Results as below:

28.PNG

 

For the Xpath expression, check:

XPath Examples

 

I also tested with the Xpath node, but havn't figure out the structure of the XML file used here.

Specifying the Xpath with node will always result in error. (need more testing, : )

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Meneghino
Level 10

Re: Having trouble with xPath, please help

Thank you @v-micsh-msft that worked!

Super User
Super User

Re: Having trouble with xPath, please help

Hi @v-micsh-msft, I'm having some trouble as well parsing XML with Flow. Can you see what I'm doing wrong?

 

  • My xml does NOT have a 'string' designator so I left 'string' out of the xpath expression
  • xpath(xml(outputs('Compose')), '(/MyModel/ASSET_ALIAS)')
  • flowXMLQuestion1.png
  • The Flow runs successfully, but the input and response just a pair of brackets when "Click to Download" are selected
  • flowXMLQuestion3.pngflowXMLQuestion.png
  • If I put 'string' into the xpath expression, the Flow also runs successfully but Compose 2 INPUTS and OUTPUTS are blank
  • flowXMLQuestion4.pngflowXMLQuestion5.png

What am I missing?

Highlighted
pratikgirdhar27
Level: Powered On

Re: Having trouble with xPath, please help

You need to replace xmnls from output. Here how I was able to replace that. 

replace(outputs('Compose_3'),'xmlns=',''
In your Flow Compose 2 Action would be 
replace(outputs('Compose'),'xmlns=',''). This would replace xmnls=. XPath queries are limited to XML without a namespace. After that I would use another Compose action to replace xmlns:i = with 
replace(outputs('Compose_4'),'xmlns:i=','')
Here is what I have done to replace xmnls . 
XML.PNG

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 369 members 4,634 guests
Please welcome our newest community members: