web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parse Xml to get my:my...
Power Automate
Answered

Parse Xml to get my:myFields and underlying tags issue

(0) ShareShare
ReportReport
Posted on by 574

Hi all!

 

I am having issues parsing an Xml file,  I have looked at:

 

- https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx

- https://powerusers.microsoft.com/t5/Building-Flows/Iterate-XML-with-flow/m-p/163734#M16546

- https://powerusers.microsoft.com/t5/General-Flow-Discussion/Parse-XML-using-Microsoft-Flow/m-p/114920#M12866

 

But i can't seem to find something to get this sort of tag (which according to me comes from InfoPath)

 

<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-01-31T13:38:00" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="nl-BE">
	<my:field1></my:field1>
 <my:field2></my:field2>
</my:myFields>

Where i would like to be able to iterate over everything that is inbetween the "my:myFields" tags.

I get the error:

 

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2562': '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.'.

 

when trying to get it like this:

xpath(xml(outputs('Compose_File_content')),'string(my:myFields)') xpath(xml(outputs('Compose_File_content')),'string(/my:myFields)') xpath(xml(outputs('Compose_File_content')),'string(//my:myFields)') xpath(xml(outputs('Compose_File_content')),string('my:myFields')) xpath(xml(outputs('Compose_File_content')),string('/my:myFields')) xpath(xml(outputs('Compose_File_content')),string('//my:myFields'))

UPDATE:
tried this as well
xpath(xml(outputs('Compose_File_content')),string('//myFields'))
xpath(xml(outputs('Compose_File_content')),string('/myFields'))
xpath(xml(outputs('Compose_File_content')),string('//field1'))
xpath(xml(outputs('Compose_File_content')),string('/field1'))
xpath(xml(outputs('Compose_File_content')),string('//myFields/field1'))
xpath(xml(outputs('Compose_File_content')),string('/myFields/field1'))
xpath(xml(outputs('Compose_File_content')),string('*/*'))
xpath(xml(outputs('Compose_File_content')),string('@*'))
xpath(xml(outputs('Compose_File_content')),string('*my:myFields'))
xpath(xml(outputs('Compose_File_content')),string('./my:myFields'))
xpath(xml(outputs('Compose_File_content')),string('my:*'))
... maybe even others i forgot 

However I am able to fetch all content that is between any tag (all in one blob) but that's the only thing I am able to grab at this time and is not what I want of course.

 

using this I am able to grab all content:

xpath(xml(outputs('Compose_File_content')),string('.'))

Can anyone advise me how i can get the value in the tags of

my:field1
my:field2

and so on, iterating over them would be preferred.

 

Thank you in advance!

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-bacao-msft Profile Picture
    Microsoft Employee on at

    Hi @dimi ,

     

    I tested it on my side using the xml data you provided. The problem seems to be related to adding xmlns.

    I removed my: and then used Expression below to get the value of field1.

    <myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-01-31T13:38:00" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="nl-BE">
    	<field1>1</field1>
     <field2>2</field2>
    </myFields>
    
    xpath(xml(outputs('Compose')),'string(/myFields/field1)')

     

    Xml can perform XPath queries, but it seems that XPath queries are limited to XML without a namespace (no xmlns). Once an XML with a namespace is encountered, the corresponding XPath query may have no results.

     

    Best Regards,

  • ITCareNV Profile Picture
    574 on at

    Hi @v-bacao-msft 


    Thank you so much for testing that out and for the explanation!

    I have created an idea here where you can vote for it.

    Thank you for your feedback!

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

    Hi @dimi ,

     

    Thank you for your feedback, if there are other alternatives, I would recommend it to you.

     

    Best Regards,

  • johan_c Profile Picture
    5 on at

    While we are waiting for custom-tags and namespace-specification to work for xpath in Flow I made a workaround that seems to work for me:

     

    I added a Compose before I use xpath where i "clean" the XML and replace strings for the tags that aren't working. In this case a Peppol-bis-order XML-file where the tags cac:... and cbc:... are common. I replaced the : with _ and use that later on in the xpath-commands

     

    On the compose named "XMLContentCleaned":

    replace(replace(replace(variables('XMLContent'),'xmlns="urn:oasis:names:specification:ubl:schema:xsd:Order-2"',''),'cac:','cac_'),'cbc:','cbc_')

    On the compose where I search the XML for the buyer-name with xpath:
    xpath(xml(outputs('XMLContentCleaned')),'string(//cac_BuyerCustomerParty/cac_Party/cac_PartyName/cbc_Name)')
  • RafaelGalvez Profile Picture
    9 on at

    I found a solution using local-name() to perform the XPath query in this post.

     

    https://powerusers.microsoft.com/t5/Building-Flows/Using-xPath-on-an-HTTP-xml-body/td-p/73531

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard