Is there any way to concatenate E4X expressions? If I store "half" a path in a variable, can I concatenate the way I do with 开发者_JAVA百科Strings?
You can always use array access by converting the E4X string into an array, seperated by the dots.
var xml:XML =
<data>
<a><b><c><x><y><z attr="This is an attribute">This is a text!</z></y></x></c></b></a>
</data>
var path1:String = "a.b.c";
var path2:String = "x.y.z";
var path3:String = "@attr";
var path:Array = ([path1, path2, path3].join('.')).split('.');
var result:XMLList = new XMLList(xml);
for (var i:uint = 0; i < path.length; i++) {
result = result[path[i]];
}
trace(result); // This is an attribute
精彩评论