How to dynamically add attributes and child nodes to an XML element in Flex

This is how I copied all the attributes of an XML node (srcXMLNode) to another XML node (dstXMLNode) in Flex, without knowing the names of those attributes:

for each(var attr:XML in srcXMLNode.attributes())
{
dstXMLNode.@[attr.name()] = attr;
}

And this is the way I added child nodes of an XML element to another:

for each(var elem:XML in srcXMLNode.elements())
{
dstXMLNode[elem.name()] = elem;
}

If you know a better way to do this, feel free to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *