I made a small example, just to know how it works.
I dont know if there is a smarter way of using the XMLobject, i guess that is what harbs's link is about, havent read that yet though.
var myRootXmlObj = new XML ("<root><fonts></fonts></root>");
var font = "";
var myInstalledFonts = app.fonts.everyItem().name;
for(i = 0; i < myInstalledFonts.length; i++) {
font = new XML ("<font>" + myInstalledFonts + "</font>");
myRootXmlObj.fonts.appendChild(font);
}
var f = new File("myTestFile.txt"); // on windows XP this goes in the user documents folder
writeXMLFile(f, myRootXmlObj);
alert(readXMLFile(f));
// rom forum thread http://forums.adobe.com/message/1114070#1114070
function writeXMLFile(file, xml) {
if (!(xml instanceof XML)) {
throw "Bad XML parameter";
}
file.encoding = "UTF8";
file.open("w", "TEXT", "????");
// unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
file.write("\uFEFF");
file.lineFeed = "unix";
file.write(xml.toXMLString());
file.close();
};
function readXMLFile(file) {
if (!file.exists) {
throw "Cannot find file: " + decodeURI(file.absoluteURI);
}
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var str = file.read();
file.close();
return new XML(str);
};