filtering XML attribute and only listing the greater [x] amount of the parent node
<book>
<name>Book 1</name>
<author age="02">Author 1</author>
</book>
<book>
<name>Book 2</name>
<author age="01">Author 2</author>
</book>
<book>
<name>Book 3</name>
<author age="04">Author 3</author>
</book>
<book>
<name>Book 4</name>
<author age="03">Author 4</author>
</book>
I need list the book name starting with the greatest of authors age but only the greater two... I would need to return the nameIn this example, the filter would list Book 3 and then Book 4, in that order.
This is hurting my brain and don'开发者_JS百科t know where to begin.
You could create Value Objects from your XML data and store them in an Array.
After that you can simply sort your Array using Array sortOn() then return the first two results.
精彩评论