Skip to main content

Notifications

Power Automate - Using Connectors
Answered

Json parse xml

(0) ShareShare
ReportReport
Posted on 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
    goliaaat 11 on at
    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
    gamoraes 1,040 on at
    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
    goliaaat 11 on at
    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
    goliaaat 11 on at
    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
    gamoraes 1,040 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard

Featured topics