Sometime it is required to convert XML to string format. OSB allows us to convert XML to string using OSB inbuilt function.

You can use the fn-bea:serialize() function if you need to represent an XML document as a string instead of as an XML element.

For example, you may want to exchange an XML document through an EJB interface and the EJB method takes String as argument. The function has the following signature:

fn-bea:serialize($input as item())

Let’s see the example:

Suppose you have an variable called result in the OSB that contained XML, and you want to convert the same into string, then you can use the following expression in Assign activity:

Let’s run the example and see the output of Assign variable:

See the xmlstring variable value.