[JS] Write XML file
I read an XML file I y contribution of the change and I want to write it in a new XML file.
I would get this presentation
but I opt cesi
Here is my code :
leDossierOEBPS = "~/Desktop/content/";
monEcritureContent(File (leDossierOEBPS + '/content.opf'),File (leDossierOEBPS + '/content5.opf'));
function monEcritureContent(refFile,refFile2) {
default xml namespace = 'http://www.idpf.org/2007/opf';
var XMLHeader = '<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>';
var XMLWorkbookHeader = "<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
var XMLWorkbookHeader2 = " xmlns=\"http\://www.idpf.org/2007/opf\" unique-identifier=\"bookid\" version=\"2.0\"";
if(refFile != null) {
refFile.open("r");
var XMLToParse = refFile.read();
refFile.close();
XMLToParse = XMLToParse.replace(XMLWorkbookHeader,"");
XMLToParse = XMLToParse.replace(XMLWorkbookHeader2,"");
var XMLData2 = new XML(XMLToParse);
XMLToParse = null;
} else {
alert("Error opening XML file.");
}
refFile2.open("w");
refFile2.encoding = "UTF8";
refFile2.writeln (XMLHeader+XMLData2.toXMLString());
refFile2.close();
}//
What is the correct control to write the XML tree?
Thank you