XML -> Object Converter not returning goods

Hey Everyone,

I have built a XML decoder that places any supplied XML data into a object and spits it back to the callee.
Everything is working so fine, the XML is being parsed, data going into its proper locations… however, when the script does its return, nothing is passed… just a object with no contents…

heres the script, can anyone see whats wrong with it?

function getXML ( tXMLData ) : Object
{
// init Counters
var i : Number = 0
var tData : Object = new Object()

while (tXMLData.childNodes* != null)
{
// Get the Data from the node
//
tData[tXMLData.childNodes*.nodeName] = tXMLData.childNodes*.childNodes[0].nodeValue

// Decode any Attributes within the Node
//
for ( var attri in tXMLData.childNodes*.attributes)
{
tData[attri] = tXMLData.childNodes*.attributes[attri]
}

// Check for Children
//
if (tXMLData.childNodes*.childNodes[0].nodeName != null)
{
tData[“sub”] = getXML ( tXMLData.childNodes* )
}

i++
}

return tData;
}

Thanks in advance for your help !!!

you are doing explicit type casting of tData to object-
tData:Object

try eliminating the explicit type- while not ‘clean code’, flash’s typecasting leaves alot to be desired and sometimes causes conflicts.

also, try setting the property to something before assigning it from the xml
tData[attri] = new String()
tData[attri] = xmldata here

i have done numerous xml style parsers to return xml data in a more user friendly package. my approach was different from yours - i created a class and sub class objects and had no issues at all.

good luck

Hi There,

Thanks for the response, I actually worked it out eventually, It was that I was not recursibvly supplying the corrent object to the function, initially I thought it was the same error [with flash’s data typing] but it turned out that it works better without it…

Thanks again !