title: LINQ - Get Max Value of a group of elements
body: <p>How can I use LINQ to query an XML structure and get a max value for a group of elements that belong to a particular element.</p>
  
  <p>For example, how could I get the maximum age allowed for FullTicket, DayTicket and ChildTicket where the XML structure looks like the below</p>
  
  <pre><code>    &lt;TicketTypes&gt;
        &lt;TicketType Name="FullTicket"&gt;
          &lt;AgeBands&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Adult1&lt;/Code&gt;
              &lt;MinAge&gt;18&lt;/MinAge&gt;
              &lt;MaxAge&gt;59&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Adult2&lt;/Code&gt;
              &lt;MinAge&gt;60&lt;/MinAge&gt;
              &lt;MaxAge&gt;64&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Adult3&lt;/Code&gt;
              &lt;MinAge&gt;65&lt;/MinAge&gt;
              &lt;MaxAge&gt;79&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
          &lt;/AgeBands&gt;
        &lt;/TicketType&gt;
        &lt;TicketType Name="DayTicket"&gt;
          &lt;AgeBands&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Adult2&lt;/Code&gt;
              &lt;MinAge&gt;18&lt;/MinAge&gt;
              &lt;MaxAge&gt;64&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Adult3&lt;/Code&gt;
              &lt;MinAge&gt;65&lt;/MinAge&gt;
              &lt;MaxAge&gt;89&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
          &lt;/AgeBands&gt;
        &lt;/TicketType&gt;
        &lt;TicketType Name="ChildTicket"&gt;
          &lt;AgeBands&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Child&lt;/Code&gt;
              &lt;MinAge&gt;3&lt;/MinAge&gt;
              &lt;MaxAge&gt;17&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
            &lt;AgeBand&gt;
              &lt;Code&gt;Infant&lt;/Code&gt;
              &lt;MinAge&gt;0&lt;/MinAge&gt;
              &lt;MaxAge&gt;2&lt;/MaxAge&gt;
            &lt;/AgeBand&gt;
          &lt;/AgeBands&gt;
        &lt;/TicketType&gt;
      &lt;/TicketTypes&gt;
  </code></pre>