简体   繁体   中英

How to replace java xml header content using XML_Transform in logic app?

I have simple logic app with Transform_XML in which i'm giving input as java xml data.

I want to replace a below string from that input java xml .

'<?xml version=\"1.0\" encoding=\"utf-16\"?>'
to
'<?xml version=\"1.0\" encoding=\"utf-8\"?>

I tried using following into code view but its not working any clue ?

 "Transform_XML": {
                "inputs": {
                                       "content": "@{xml(replace(string(triggerBody()),'<?xml version=\"1.0\" encoding=\"utf-16\"?>','<?xml version=\"1.0\" encoding=\"utf-8\"?>'))}",

                    "integrationAccount": {
                        "map": {
                            "name": "mytestmap"
                        }
                    }
                },
                "runAfter": {},
                "type": "Xslt"
            }

But at Xml Validation it is giving error -

InvalidXml. The provided content must be of XML content type.

The replace() looks correct, but you probably don't need to use xml() at this point.

If the content from the Trigger is coming in as base64, you may need to do a base64ToString() first as replace() may be trying to act on the base64 content instead. Some Actions handle this correctly, other don't.

replace(base64ToString(triggerBody()),'',''))}"

But...be very careful changing the header like this since now you're obligated to send it as full UTF to any downstream clients.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM