Well, I don't know if Flex has any build-in mechanism for dealing with such situation (I don't suppose it does) but I certainly can help you make your function more versatile
functionupdateXml(xml:XML, path:String, data:String):void {
varnodesArray:Array = path.split(".");
vartempXML:XML = xml;
vartempXMLCandidate:XML;
vartagName:String;
for (vari:int = 0; i < nodesArray.length; i++){
tagName = nodesArray[i];
if (i == nodesArray.length - 1){
tempXML[tagName] = data;
}else{
tempXMLCandidate = tempXML[tagName][0];
if (!tempXMLCandidate){
tempXMLCandidate = <{tagName}>;
tempXML.appendChild(tempXMLCandidate);
}
tempXML = tempXMLCandidate;
}
}
}
I keep my fingers crossed however so someone would help you with some build-in solution, I'm curious about it myself.
Cheers.
Post a Comment for "Updating An Actionscript Xml Object Directly In One Line Using E4x?"