thanks a lot for the code. It was not working the first time (do not recognize item and existing_time --> i changed item by r[-1] and existing_time by existing_equip).
however, it is not producing the result i expected, as in it doesn't group by same category the elements, it creates a new block of xml <results> - <LINK id="23"> - <EQUIPMENT id="jr2"> - <TIMESTAMP id="3pm"> <data>my first value</data> </TIMESTAMP> </EQUIPMENT> </LINK> - <LINK id="23"> - <EQUIPMENT id="jr1"> - <TIMESTAMP id="3pm"> <data>my second value</data> </TIMESTAMP> </EQUIPMENT> </LINK> - <LINK id="23"> - <EQUIPMENT id="jr2"> - <TIMESTAMP id="3pm"> <data>my third value</data> </TIMESTAMP> </EQUIPMENT> </LINK> - <LINK id="24"> - <EQUIPMENT id="jr2"> - <TIMESTAMP id="3pm"> <data>my fourth value</data> </TIMESTAMP> </EQUIPMENT> </LINK> - <LINK id="25"> - <EQUIPMENT id="jr2"> - <TIMESTAMP id="3pm"> <data>my fifth value</data> </TIMESTAMP> </EQUIPMENT> </LINK> - <LINK id="25"> <EQUIPMENT id="jr2"> <TIMESTAMP id="4pm"> <data>my sixth value</data> </TIMESTAMP> </EQUIPMENT> </LINK> </results> The idea behind all that is : i want to create an xml file that'll have a XSL instructions. The xsl will sort the entries and display something like : Route 23: *jr1 *3pm value value value *5pm value value *jr2 *3pm value value value *5pm value value Route 29 *jr1 *3pm value value value *5pm value value *jr2 *3pm value value value *5pm value value I know this is feasible with XSL2 , but i need something compatible with quite old browser, and XSL2 is not even working on my comp( i could upgrade but i cannot ask all the users to do so). That's why I thought rearranging the xml would do it. Do you have other idea? Do u think it is the best choice? More information abt the application I am writing : i am parsing a feed, extracting some data and producing reports. the application is running on spyce, so i don't have to produce a file in output, just print the xml to the screen and it is automatically wrting to the html page we view. Thanks again for your help. Gerard Flanagan wrote: > Gerard Flanagan wrote: > > kepioo wrote: > > > Hi all, > > > > > > I am trying to write an xml aggregator, but so far, i've been failing > > > miserably. > > > > > > what i want to do : > > > > > > i have entries, in a list format :[[key1,value],[key2,value],[ > > > key3,value]], value] > > > > > > example : > > > [["route","23"],["equip","jr2"],["time","3pm"]],"my first value"] > > > [["route","23"],["equip","jr1"],["time","3pm"]],"my second value"] > > > [["route","23"],["equip","jr2"],["time","3pm"]],"my third value"] > > > [["route","24"],["equip","jr2"],["time","3pm"]],"my fourth value"] > > > [["route","25"],["equip","jr2"],["time","3pm"]],'"my fifth value"] > > > > > > > [snip example data] > > > > > > > > > > > If anyone has an idea of implemetation or any code ( i was trying with > > > ElementTree... > > > > > > > (You should have posted the code you tried) > > > > The code below might help (though you should test it more than I have). > > The 'findall' function comes from here: > > > > http://gflanagan.net/site/python/elementfilter/elementfilter.py > > > > it's not the elementtree one. > > > > Sorry, elementfilter.py was a bit broken - fixed now. Use the current > one and change the code I posted to: > > [...] > existing_route = findall(results, "[EMAIL PROTECTED]" % routeid) > #changed line > if existing_route: > route = existing_route[0] > existing_equip = findall(route, "[EMAIL PROTECTED]'%s']" % equipid) > if existing_equip: > [...] > > ie. don't quote the route id since it's numeric. > > Gerard -- http://mail.python.org/mailman/listinfo/python-list