XML : How to find Min and Max value of xml element

Can anyone help me with this problem?

I have to find the Min and Max months according to expenses values:

  <?xml version="1.0" encoding="UTF-8"?>  <shop>     <month>Jan</month>     <expense>2520,50€</expense>     <month>Feb</month>     <expense>2900,00€</expense>     <month>Mar</month>     <expense>1000,00€</expense>     <month>Apr</month>     <expense>1520,00€</expense>     <month>May</month>     <expense>500,00€</expense>     <month>Jun</month>     <expense>1250,50€</expense>     <month>Jul</month>     <expense>300,00€</expense>     <month>Aug</month>     <expense>0,00€</expense>   </shop>    

I already tried with XPath but without success...

  XmlDocument doc = new XmlDocument();  doc.Load("XML/despesas.xml");    XmlNode node = doc.SelectSingleNode("//loja/expense[not(. <=../preceding-sibling::expense) and not(. <=../following-sibling::expense)]");  int min = Convert.ToInt32(node.Value);    

No comments:

Post a Comment