cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Community Champion
Community Champion

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
Highlighted
Community Support
Community Support

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
Highlighted
Community Support
Community Support

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

Highlighted
Community Champion
Community Champion

Re: Having trouble with xPath, please help

Thank you @v-micsh-msft that worked!

Highlighted
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
Frequent Visitor

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

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (6,728)