
Or if we format and look at it, the Name and the Newsletters is the same Root level – Also, when it is not an Array already, but there are Multiple Attributes at the Root level itself, it won’t work either.The provided value cannot be converted to XML:’Data at the root level is invalid…“ It will result in the below error saying, “ The template language function ‘xml’ parameter is not valid. You cannot have an Array of JSON elements which looks like below – Cannot use an Array and there can be only 1 Root element.

And if we take it to an XML formatter, it’ll look like below.Now, since I’m storing my JSON data in String already, I’m converting it to JSON by using json() function inside the xml() function. Next, we can use the formula xml() in the expressions and use it as below.If I format the same data in JSON formatter online, it’ll look like this –.I’ll store the same in a variable which looks like below. So starting off with JSON data, you’ll need a String based JSON data.Let’s look at an example where we have a sample JSON which we will convert to XML in Power Automate using xml() function and we’ll revert the same operation using xml() function in Power Automate itself. String xml = xmlMapper.In this very simple post, let’s look at how you can convert JSON to XML and XML back to JSON while working in Power Automate.įirst, let’s look at converting JSON to XML and then, XML to JSON from the same result of the first conversion. ObjectNode objectNode = jsonMapper.readValue(json, ObjectNode.class) JsonMapper jsonMapper = new JsonMapper()

void testXmlToJson() throws IOException " Once we have the POJO, we can write it to JSON format as any regular class. After we have the XML string, we can use XmlMapper to parse into POJO. We can read the XML from various sources, even from an API call.
