Sort XML elements by certain attributes

tanrock

New Member
I would need to sort an XML document that looks like follows:\[code\]<root xmlns="http://my.name.space.com"> <product id="id001"> <datafield name="Name" value="http://stackoverflow.com/questions/15790089/value 1"/> <datafield name="Description" value="http://stackoverflow.com/questions/15790089/descriptive text"/> <dataAttribute id="id002"> <datafield name="Name" value="http://stackoverflow.com/questions/15790089/ZZZZZ"/> <datafield name="Start Date" value="http://stackoverflow.com/questions/15790089/16/01/2010 00:00:00"/> <datafield name="End Date" value=""/> <datafield name="Status" value="http://stackoverflow.com/questions/15790089/Active"/> </dataAttribute> <dataAttribute id="id003"> <datafield name="Name" value="http://stackoverflow.com/questions/15790089/XXXXX"/> <datafield name="Start Date" value="http://stackoverflow.com/questions/15790089/16/01/2010 00:00:00"/> <datafield name="End Date" value=""/> <datafield name="Status" value="http://stackoverflow.com/questions/15790089/Active"/> </dataAttribute> <dataAttribute id="id004"> <datafield name="Name" value="http://stackoverflow.com/questions/15790089/YYYYY"/> <datafield name="Start Date" value="http://stackoverflow.com/questions/15790089/16/01/2010 00:00:00"/> <datafield name="End Date" value=""/> <datafield name="Status" value="http://stackoverflow.com/questions/15790089/Active"/> </dataAttribute> </product></root>\[/code\]The dataAttribute elements should be sorted, by the one which @name Attribute = "Name" but the sorting should occure by this element's @value attribute.Do you have any hints on this?Thank you very much!Fritz
 
Back
Top