Skip to main content
Community site session details

Community site session details

Session Id : QBDc6JA7cWnspN0Gb0LKsP
Power Automate - General Discussion
Answered

XML convert to other XML format

Like (0) ShareShare
ReportReport
Posted on 23 Apr 2019 13:00:48 by

Hi,

 

I want to transform XML data to another XML format, I receive it by e-mail. 

In Flow I created receive from mail, that works well, from a simple XML I get a xml value with xpath. 

 

But from the XML below I cannot get the UniqueCreatorIdentification value.

I use this code:

xpath(xml(body('Bijlage_ophalen')), 'string(/pay:invoice/invoiceIdentification/uniqueCreatorIdentification)')

 

What is wrong with this code?
Is this te best way to transform a XML to another format XML or is there a better way?

I want to use compose to put the values from the original file into the new file and save the file in the new format XML and store it with FTP.

 

Kind regards,

Rob

<?xml version="1.0" encoding="UTF-8" ?>
<pay:invoice xmlns:pay="urn:ean.ucc:pay:2" xmlns:eanucc="urn:ean.ucc:2" xmlns:px="urn:ean.ucc:pay:vat:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ean.ucc:pay:2 Factuur_bou002.xsd" creationDateTime="" documentStatus="ORIGINAL">
documentStructureVersion>
 <versionIdentification>002</versionIdentification>
 </documentStructureVersion>
<invoiceIdentification>
 <uniqueCreatorIdentification>452823</uniqueCreatorIdentification>
<contentOwner>
 <gln>8714xxxxxxxxxx</gln>
 </contentOwner>
 </invoiceIdentification>
<invoiceCurrency>
 <currencyISOCode>EUR</currencyISOCode>
 </invoiceCurrency>
 <invoiceType>INVOICE</invoiceType>
<shipTo>
 <gln>0000000000000</gln>
 </shipTo>
.. and further..
  • sushmitasingh Profile Picture
    on 02 Dec 2022 at 07:26:47
    Re: XML convert to other XML format

    Is there any tool/software to do this in easiest form please suggest.

  • Meverick Profile Picture
    12 on 02 Dec 2022 at 05:05:47
    Re: XML convert to other XML format

    Converting an XML document to another format

    Specify the XML document to be converted in the Input file text field.
    Choose the conversion using the Conversion specification combobox.
    Specify the output file or directory in the Output file text field.

     

     

    Greetings,
    Maverick

  • v-bacao-msft Profile Picture
    on 01 May 2019 at 01:33:54
    Re: XML convert to other XML format

    Hi @rob3 ,

     

    Thank for your feedback.

    And if your problem has been resolved, please click “Accept as Solution” and mark the post as solved, so that more users can see a similar resolution.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on 29 Apr 2019 at 06:15:43
    Re: XML convert to other XML format

    I don't  know what I did wrong, but afther a few tests is it working now.

    Thanks for you help!!

  • Verified answer
    v-bacao-msft Profile Picture
    on 26 Apr 2019 at 03:14:32
    Re: XML convert to other XML format

    Hi @rob3 ,

     

    Could you share all the details of your configuration?

    This is not a problem with base64ToString() function. It is clear in the Flow run history that ContentBytes is null.

    So the first parameter passed to the base64ToString() function is null.

    Please ensure that Include Attachments field value is Yes.

    Image reference:

    43.PNG

    Please take a try again.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on 25 Apr 2019 at 13:59:24
    Re: XML convert to other XML format

    Hi Barry,


    Thanks for your reply!

     

    Unfortunately I get an error:

    InvalidTemplate. Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '2594': 'The template language function 'base64ToString' expects its parameter to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#base64ToString for usage details.'.

     

    See the: Printscreen

    Seems it has the XML file, but the transform with the base64tostring isn't working.

     

    Kind regards,

    Rob

     

  • v-bacao-msft Profile Picture
    on 25 Apr 2019 at 09:50:57
    Re: XML convert to other XML format

    Hi @rob3 ,

     

    Please try using base64ToString() function to convert the Attachment content to a String value, then using replace() function.

     

    Expression reference:

    base64ToString(item()['ContentBytes'])

    Image reference:

    33.PNG

    34.PNG

    Please take a try.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on 25 Apr 2019 at 08:28:12
    Re: XML convert to other XML format

    Hi Barry,

     

    Thanks for your reply!

    If I do the same as you it works, but when I receive a XML file by e-mail I get an error.

    The error is:

     

    InvalidTemplate. Unable to process template language expressions in action 'Replace' inputs at line '1' and column '2594': 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#replace for usage details.'.

     

    I receive the e-mail, get the attachement, put the body of the attachement in a compose, then I use the replace function.

    Printscreen

    Printscreen

     

    Hopefully you can help me with this issue.


    Kind regards,

    Rob

     

  • v-bacao-msft Profile Picture
    on 24 Apr 2019 at 02:46:59
    Re: XML convert to other XML format

    Hi @rob3 ,

     

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

    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.

     

    What I can do for you is remove pay: so that we can use xpath() function to get the value of the specified element. This may be contrary to your intention, but this is a practice that can be considered.

    I tested it with the XML you provided. It seems that there is an escape character, and documentStructureVersion is missing "<". After modification, the value of the specified element is obtained by the following method.

     

    Expression:

    replace(outputs('Compose'),'pay:','')
    xpath(xml(outputs('Compose_2')),'string(/invoice/invoiceIdentification/uniqueCreatorIdentification)')

    Image reference:

    6.PNG

    Flow run history:

    7.PNG

    Hope it helps.

     

    Best Regards,

  • Brad_Groux Profile Picture
    4,556 on 23 Apr 2019 at 14:03:15
    Re: XML convert to other XML format

    First, I'd recommend reviewing the official Data Operations documentation and the Trigger a Flow with Email documentation as a refresher. The Microsoft Flow Community post, Modify Dynamic Content Before Use in Flow may help as well.

    You should be able to perform the conversion you're seeking using Flow's Logical Expressions and Functions. If you provide a detailed and expanded screenshot of your Flow, as well as the error messages you receive while saving or running your Flow, we may be able to assist further.

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. THANKS!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1

Loading complete