-
“new XML()” not working sometimes on Extendscript
Hi,I’m creating XML objects with this sintax:
var element = "element";
var xml = new XML("<"+element+"/>");But sometimes it doesn’t work. On the navigation tab, in the toolkit, “xml” appears as an empty xml object.
For example, in this code:
function KT_Data(name, value){
this.name = (!name)?this.constructor.name : name;
this.value = (!value)?0: value;this.toXml = function(xml) {
var newXml = new XML("<" + this.name+ "/>"); //WORKS
newXml.@type = "KT_Data";
newXml.@class = this.constructor.name;
for (var property in this) {
var prop = this[property];
if (typeof prop == "function") {continue}
if (prop instanceof KT_Data){
prop.toXml(newXml);
} else if (prop instanceof Array) {
this.arrayToXml(newXml, prop, property);
} else {
newXml[property] = prop;
}
}
xml.appendChild(newXml);
return xml
}this.arrayToXml = function(xml, property, nodeName) {
var newXml = new XML("<" + nodeName+ "/>"); //NOT WORKING
newXml.@type = "Array";
for (var i = 0; i < property.length; i++) {
var element = property[i];
var childXml = new XML("It works when I create the root element and inside toXml() function, but not working inside arrayToXml().
Someone can figure out why is this happening?
Sorry, there were no replies found.