Expand my Community achievements bar.

How to make an XML in form of String to well-formed XML document

Avatar

Level 4

Hi Folks,

     Thanks for all you support in Advance, i have a requirement, where i have an XML in one line string form and i wondering how to convert into well formed XML?

Input XML sample:

<root> <one><link1></link1></one><two></two> </root>

to well-formed XML

<root>

      <one>

          <link1></link1>

     </one>

     <two>

     </two>

</root>

I was trying to create a well-formed document using DOM or SAX parsers in ExcuteScript activity, but it is leading to some complicated exceptions. And i am looking for the simplest way for transformation.

Please let me know

thanks,

Rajesh

4 Replies

Avatar

Former Community Member

In a Set Value operation use the deserialize() function found in the Misc group, where xmlDoc is of type 'xml' and xmlStr is of type 'string'.

Untitled.png

Steve

Avatar

Level 4

Thank you Steve, i tried DeSerializing the string to XML, but when i view the final XML i still see the XML is NOT well formed. i don't know where i am commiting mistakes. please find my sample process and investigate.

https://acrobat.com/#d=Ykz0yeJxJ9YmBwXPS68fQw

thanking you,

Rajesh

Avatar

Former Community Member

Rajesh,

I don't understand. There is no difference between the two XML instances other than whitespace. They are both well-formed XML.

<root> <one><link1></link1></one><two></two> </root>

<root>

      <one>

          <link1></link1>

     </one>

     <two>

     </two>

</root>

Steve

Avatar

Level 5

Rajesh,

I believe you might want to look at this:

You can use saveXML('pretty') to get a well formatted XML..

Check this article..

http://forms.stefcameron.com/2009/08/19/tip-pretty-xml-strings/

Mark