Hello:
I’m working with Senocular’s code for formatting XML from the tutorial. I am developing a RIA that loads and writes to XML, and want to keep the XML file readable for my edification (not one ridiculously-long line.)
http://www.kirupa.com/web/xml/XMLmanageData7.htm
Trying to get this to work first with some simple in-line XML:
var x1:XML = new XML("<item><a id=‘1’ /><a id=‘2’ /><a id=‘3’ /></item>");
// formats XML into a multi-lined, indented format
// a good toString replacement for XML with ignoreWhite = true
XMLNode.prototype.format = function(indent) {
if (indent == undefined) {
indent = “”;
}
var str = “”;
var currNode = this.firstChild;
do {
if (currNode.hasChildNodes()) {
str += indent + currNode.cloneNode(0).toString().slice(0, -2) + ">
";
str += currNode.format(indent + " ");
str += indent + “</” + currNode.nodeName + ">
";
} else {
str += indent + currNode.toString() + "
";
}
} while (currNode = currNode.nextSibling);
return str;
};
Need to know the appropriate syntax to CALL this function so I can trace the output to see if it’s worked. Thanks.