XML - append child
Hi,
I am generating new xml from existing xml by reading as xml. Reading elements (specific elements) and appending it into new xml file by using appendChild of xml method. The element which I appending have nested elements so that final xml have the nested elements as new line without space before. But i am appending with space and the elements. pls. refer the below screenshots.

Code:
xmlProcess();
function xmlProcess() {
var root = new XML("<root></root>");
var child = new XML("<child>Child 1</child>");
root.appendChild(child);
var child2 = new XML("<child>Child 2 <emph>test contents</emph></child>"); //
root.appendChild(child2);
var file = new File("~/Desktop/test.xml");
var xml = root.toXMLString();
file.open("W");
file.write(xml);
file.close();
var doc = app.activeDocument;
doc.importXML(file);
};
How to append the element in a single line as it is given in a string..



