Ok- here's a painfully easy one I bet --
开发者_JAVA技巧I'm aware of how to use EX4 to filter most pieces of the xml I need
- however how can I filter an XML list such as the one below to check say --- if a dog is a beagle? preferably as a Boolean.
var theXml:XML =
<animals> <animal dog ="poodle" cat="Siamese" /> <animal dog ="beagle" cat="calico" /> <animal dog ="mutt" cat="tabby" /> </animals>
var animalList:XMLList = theXml.animals.animal;
this ended up working ( thanks Tyler )...
if (theXml.animals.animal.(@dog == "beagle").length > 0) {
trace('match')
}
thanks ! -MW
I love the power of E4X, here's the example of what you are looking for:
theXml.animals.animal.(@dog == 'beagle');
If it finds a match it'll return it.
EDIT
To answere your question below:
var xml:XML = <a id="34"></a>;
//traces
if (xml.(@id == '34').length() != 0) {
trace('match')
}
//no trace
if (xml.(@id == '35').length() != 0) {
trace('match')
}
You shouldn't need the root node "animals":
theXml.animal.(@dog == 'beagle');
精彩评论