Glen Pike
Thu, 27 Aug 2009 07:53:14 -0700
Hi,I have a project where we are passing XML via a socket to a C++ based server and there is an issue with the ordering of XML elements inside a packet.
In AS3, I am assembling a packet with a <parameters> element that contains 1 or more children with <name>value</name> type syntax. Because the "params" are passed into a generic function, I am looping through an object as follows:
//if params, loop through params, create params.
if (null != params) {
cmd.command.appendChild(<parameters/>);
for (var par:* in params) {
//var val:String = ;
var parXML:XML =
<{par}>{params[par].toString()}</{par}>;
cmd.command.parameters.appendChild(parXML);
}
}
The C++ guy is asking if I can send these parameters in a specific
order, but I can't see any way to guarantee that order without
hardcoding, or using an indexed array, which implies hardcoding
somewhere else.
Does anyone know of a way to do this - I suppose I could loop through the object, get the property "keys", sort these, then loop through the result to read values, but guessing thats the only way.
I could also argue that the back end needs to use an XML parser that does not care about element order, so if anyone has any tips on that, it would be appreciated.
Ta glen _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders