c# - Sort XmlNodeList with a specific Node value -
i searched web this, not able find related solution.
i have following xml
  <table>     <entity>employee</entity>     <entityid>2786</entityid>     <goal>       <goalid>31931</goalid>       <filterdata>lastmodifiedon¥2014-03-20t18:11:01.0000000+05:30Æactivetaskcount¥0</filterdata>     </goal>     <goal>       <goalid>31932</goalid>       <filterdata>lastmodifiedon¥2014-03-22t15:26:09.0000000+05:30Æactivetaskcount¥0</filterdata>     </goal>     <goal>       <goalid>31932</goalid>       <filterdata>lastmodifiedon¥2014-03-22t09:25:00.0000000+05:30Æactivetaskcount¥0</filterdata>     </goal>   </table>  from above xml when read data  got 2 separate datatables; 1 employees , 1  related goals.
what needed want sort goals related employee respect lastmodifiedon filterdata node.
note: getting lastmodifiedon value split node value this
nodevalue.split('Æ')[0].split('¥')[1] right using system.xml namespace doing operations. looked @ linq xml unable make work.
i getting xmlnodelist following code
xmlnodelist goalnodeslist = doc.documentelement.selectnodes("/newdataset/table[entity='employee' , entityid='" + entityid + "']/goal");
here want sorted goals (with respect lastmodifiedon).
i looked @ useful links didn't idea far
i ready convert code linq xml needed brief example.
one thing try creating collection of key value pairs key goal , value date. override compareto method comparing dates , use [collection name].sort(). hope helps
Comments
Post a Comment