Reputation: 357
I want to get all xml elements (xml descendents) which have some attributes like:
<books>
<book concept="rr" author="xx"/>
<book concept="tt" />
<book concept="yy" />
<book concept="uu" author="xx"/>
</books>
I need to perform a xml descendent search for xml nodes with author attribute containing results should be:
<book concept="rr" author="xx"/>
<book concept="uu" author="xx"/>
Upvotes: 1
Views: 344
Reputation: 9897
Or with XML selectors:
var booksXML: XML = <books>
<book concept="rr" author="xx"/>
<book concept="tt" />
<book concept="yy" />
<book concept="uu" author="xx"/>
</books>
var haveAuthor:XMLList = booksXML.book.(attribute("author").length() > 0);
//booksXML.book.(@author) won't work
Upvotes: 0
Reputation: 13327
This should answer your question:
var booksXML: XML = <books>
<book concept="rr" author="xx"/>
<book concept="tt" />
<book concept="yy" />
<book concept="uu" author="xx"/>
</books>
for each (var xmlBook: XML in booksXML.children())
{
if (xmlBook.@author != undefined)
trace(xmlBook.toXMLString());
}
Upvotes: 1