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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

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

Categories:
I have the same question (0)
  • gamoraes Profile Picture
    1,040 on at

    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

  • goliaaat Profile Picture
    11 on at
    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
  • goliaaat Profile Picture
    11 on at

    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

  • Verified answer
    gamoraes Profile Picture
    1,040 on at

    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 at

    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

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard