Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 4/Wv7nHI1CZQFRfpHgi8q9
Power Automate - Using Connectors
Answered

Json parse xml

Like (0) ShareShare
ReportReport
Posted on 17 Aug 2017 12:48:52 by 11

Hello, this is my first post so sorry for the language errors

 

My question is how to remove an xml row so that I read the json data

<? Wersja xml = "1.0" encoding = "utf-8"?> <String xmlns = "http://tempuri.org/"> łańcuch </ string>

 

Screenshot_20170817-143201.pngScreenshot_20170817-143238.pngScreenshot_20170817-143339.png

  • goliaaat Profile Picture
    11 on 24 Aug 2017 at 06:02:01
    Re: Json parse xml

    Thank you very much for help @gamoraes

     

    My mistake was that I did not know how to write the expression.

     

    For beginners show my flow

     

     

    1.png2.png3.png4.png5.png

     

  • Verified answer
    gamoraes Profile Picture
    1,040 on 22 Aug 2017 at 12:12:37
    Re: Json parse xml

    Hi @goliaaat sorry for the delay, and thanks to post the webservice, help a lot.

     

    You need to use this expression in your compose:

     

    json(replace(replace(replace(actionBody('HTTP'),'<?xml version="1.0" encoding="utf-8"?>',''),'<string xmlns="http://tempuri.org/">',''),'</string>',''))

     

    where the text in red is the name of your Http Action, with this function you'll have only the json and in json type for use, if you need only strng, can remove the json text of expression

     

    Best Regards,

     

    Gustavo Moraes

  • goliaaat Profile Picture
    11 on 21 Aug 2017 at 18:57:59
    Re: Json parse xml

    Hello
    He tried different json forms and every time there is an error

     

     

    {
     "?xml": {
     "version": "1.0",
     "encoding": "utf-8"
     },
     "string": {
     "xmlns": "http://tempuri.org/"
     },
     "root": {
    "person": [{
    "type": "object",
    "properties": {
    "ZP_400_Kryteria": {
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "GuidZP400": {
    "type": "string"
    },
    "Kryteria": {
    "type": "string"
    },
    "Znaczenie": {
    "type": "string"
    }
    },
    "required": ["GuidZP400", "Kryteria", "Znaczenie"]
    }
    }
    }
    }
    
    ]
    }
    }

    error code

     

    „Unexpected character encountered while parsing value: <. Path '', line 0, position 0.”

     

    The fact that I do not know the json programming of the second option can not be implemented.

     

     

    PublicWebService information page

    http://websrv.bzp.uzp.gov.pl/BZP_PublicWebService.asmx?op=KryteriaDoZP400_JSON

    Body

    _ZP400Guid=ba1f8e2d-5d57-4c0f-8ad7-83537f9aaba1

     

    Please help @gamoraes

  • goliaaat Profile Picture
    11 on 18 Aug 2017 at 09:42:57
    Re: Json parse xml
    Thank you for your answer.
    I tried the first method and it returns an error ("@version" "left parenthesis" "endofdata" )

    My code

    {
    "?xml": {
    "@version": "1.0",
    "@encoding": "utf-8"
    },
    "root": {
    "person": [{
    "type": "object",
    "properties": {
    "ZP_400_Kryteria": {
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "GuidZP400": {
    "type": "string"
    },
    "Kryteria": {
    "type": "string"
    },
    "Znaczenie": {
    "type": "string"
    }
    },
    "required": ["GuidZP400", "Kryteria", "Znaczenie"]
    }
    }
    }
    }

    ]
    }
    }

    The second method I can not write code
  • gamoraes Profile Picture
    1,040 on 17 Aug 2017 at 20:18:11
    Re: Json parse xml

    Hi @goliaaat

     

    You can use 2 functions to resolve your problem:

     

    1- Use Json() expression to parse this string in a compose and after access the correct property:

     Input = "<?xml version="1.0"?> <root> <person id='1'> <name>Alan</name> <occupation>Engineer</occupation> </person> </root>"

     

     Example = Json("<?xml version='1.0'?> <root> <person id='1'> <name>Alan</name> <occupation>Engineer</occupation> </person> </root>")

     

    Output = "{ "?xml": { "@version": "1.0" }, "root": { "person": [ { "@id": "1", "name": "Alan", "occupation": "Engineer" } ] } }"

     

    2 - Use Replace expression to remove the literal text <xml....>

    Example = replace('the old string', 'old', 'new')

     

    Hope Have Helped,

     

    Gustavo Moraes

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard

Featured topics

Loading started