So I've got an xml like this stored in a variable in Flex AS3
var xm:XML=<licenses>
<license id="7" name="No known copyright restrictions" url="http://flickr.com/commons/usage/" />
<license id="4" name="Attribution License" url="http://creativecommons.org/licenses/by/2.0/" />
<license id="6" name="Attribution-NoDerivs License" url="http://creativecommons.org/licenses/by-nd/2.0/" />
<license id="3" name="Attribution-NonCommercial-NoDerivs License" url="http://creativecommons.org/licenses/by-nc-nd/2.0/" />
<license id="2" name="Attribution-NonCommercial License" url="http://creativecommons.org/licenses/by-nc/2.0/" />
<license id="1" name="Attribution-NonCommercial-ShareAlike License" url="http://creativecommons.org/licenses/by-nc-sa/2.0/" />
<license id="5" name="Attribution-ShareAlike License" url="http://creativecommons.org/licenses/by-sa/2.0/" />
</licenses>
And the Flickr API is returning the license of a photo, which is parsed and put in an object. Lets say the license Id for a particular photo is accessible as
myPhoto.licenseId;
How do I look for which license belongs to the given licenseId?
I've tried
var x1:Object=(xm.licenses.license.name.(@id==myPhoto.licenseId.toString()));
var x2:Object=(xm.license.name.(@id==myPhoto.licenseId.toString()));
var x3:Object=(xm.licenses.license.(@id==myPhoto.licenseId.toString()));
But they all return an empty XMLList
Also, not putting the toString()
gives the same result.
Been stuck on this for a few hours now and it gets more frustrating everytime I think about it. Any way I can fix it?
The Doh! monster strikes again!!
I now notice I was trying to access xm.licenses.license
. This is wrong because <licenses>
is the root for the xml. The correct one is
xm.license.(@id==myPhoto.licenseId.toString());