Skip to main content
Power Automate
    • Connectors
    • Templates
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process advisor
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Advisor
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • Events
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • Re: Parsing XML with wierd structure into JSON obj...

    Re: Parsing XML with wierd structure into JSON object

    12-03-2021 10:41 AM

    paulburnett224
    Advocate I
    922 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    paulburnett224
    paulburnett224 Advocate I
    Advocate I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Parsing XML with wierd structure into JSON object

    ‎12-03-2021 09:08 AM

    Hello:

    I have been working on parsing this XML using the xpath() and xml() functions.   Everything is working great except for this bit of XML structure, see the bottom.  Looking for some advice. 

     

    Each 3 fields (Name, Type, Value) are a matched set (there are actually 36 of these, shorted in this message).  I only care about the name and value.   I am wanting to make a JSON look like the following:

    {

       "dcname": "Bottom Cleat",

       "name": "Bottom Cleat",

       "wallname": "Wall B"

    }

     

    I have this working, but it is very time expensive. What I did is use xpath on the label name and create an array using an incremental variable to run through the Apply to Each for each Name value. I then repeated the process for the xml value. I then stitched them together.

    paulburnett224_4-1638549367368.png

     

    paulburnett224_2-1638549337537.png

     

    [

         {

            "LoopNo": 1,

            "LabelName": "dcname"

         },

        {

           "LoopNo": 2,

           "LabelName": "name"

        },

        {

           "LoopNo": 3,

           "LabelName": "wallname"

        }

    ]

     

     The repeated the process for the “Value” field

    paulburnett224_3-1638549359399.png

     

    [

         {

            "LoopNo": 1,

            "LabelValue": " Bottom Cleat "

         },

        {

           "LoopNo": 2,

           " LabelValue ": " Bottom Cleat "

        },

        {

           "LoopNo": 3,

           " LabelValue ": " Wall B "

        }

    ]

     

    I then stitched them together by running through the name array and then filtering for the value array matching the LoopNo and using the addproperty() to created the following JSON

    paulburnett224_5-1638549416621.png

     

     {

       "dcname": "Bottom Cleat",

       "name": "Bottom Cleat",

       "wallname": "Wall B"

    }

     

    End Result Took 48 seconds to run, I have a potential of 100s of these to run = Hours of time.

    paulburnett224_6-1638549448506.png

     

     

    Here is the source XML (shorted down from 36 rows)

    <Label ID="IDL-0" JobID="IDJ-0" PartID="IDP-0">
         <Name>dcname</Name>
         <Type>text</Type>
         <Value>Bottom Cleat</Value>
         <Name>name</Name>
         <Type>text</Type>
         <Value>Bottom Cleat</Value>
         <Name>wallname</Name>
         <Type>text</Type>
         <Value>Wall B</Value>
    </Label>

     

     

     

    Preview file
    82 KB
    XMLtoJSONObject.zip
    Labels:
    • Labels:
    • Automated Flows
    • Button flows
    • Scheduled flows
    Message 1 of 2
    937 Views
    0 Kudos
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    paulburnett224
    paulburnett224 Advocate I
    Advocate I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎12-03-2021 10:41 AM

    I included a zipped flow of this process.   Need to get to run faster.  1 hour for 86 (36 row XML) is way too slow.   I cannot run concurrency because the increment integer variable because the way it is built I have to match the record location. 

    Message 2 of 2
    922 Views
    0 Kudos
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2023 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices