cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meneghino
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
v-micsh-msft
Community Support
Community Support

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
v-micsh-msft
Community Support
Community Support

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.

Thank you @v-micsh-msft that worked!

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?

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
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,756)