Re: sorting xml nodes in freemarker

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
<#list doc.games.game?sort_by("@name") as game>
  ${game.@@markup} <#-- assuming you want to print the "game" tags -->
</#list>

See also:
http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_sort_by
http://freemarker.org/docs/xgui_imperative_formal.html


Saturday, November 14, 2009, 1:47:50 AM, kgupta wrote:

> I forgot to mention assume the sort criteria is sort by attribute name.
>
> kgupta wrote:
>> 
>> Hi,
>> 
>> Suppose I have the following xml
>> 
>> <games>
>>     <game name = "b">
>>     <game name = "a">
>>     <game name = "c">
>> </games>
>> 
>> How do I use the sort_by or the sort built in function to sort the nodes?
>> What would be the syntax?
>> 
>> Thanks,
>> Kunal
>> 
>> 
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.