I had already referred this following link but could not find the solution for my scenario.Actionscript 3 - How can i convert from XMLList to XML?My xml variable is as followsrivate var checkXml:XML = new XML(\[code\]<item name="cat 2"> <item name = "All"/> <item name = "item 1"/> <item name = "item 2"/> </item> <item name="cat 2"> <item name = "All"/> <item name = "item 3"/> <item name = "item 4"/> <item name = "item 5"/> <item name = "item 5"/> </item> <item name="cat 3"> <item name = "All 33"/> <item name = "item 34"/> <item name = "item 44"/> </item>\[/code\]); I use a filter function to remove the duplicate values in above xml as:\[code\]private function filter(xmlSample:XML):XMLList { var seen:Object={} return xmlSample..@name.(!seen[valueOf()]&&(seen[valueOf()]=true)) } which returns XMLList data.When I use this to get an XML format as: var thisXml:XMLList = filter(checkXml); Alert.show(thisXml.toXMLString()); I do not get the output in XML format;I get it this way.: cat 2 All item 1 item 2 item 3 item 4 item 5 cat 3 All 33 item 34 item 44 How to get the same in XML format in Flex like that of my XML variable "checkXml".,so that I can retain all the parent nodes and child nodes as it is thereby the duplicates getting removed.\[/code\]