 <p>Some alternative using Linq to Xml</p> <pre><code>using System.Xml.XPath; var document = XDocument.Parse(@"&lt;Z&gt; &lt;X&gt; &lt;Code&gt;ABC&lt;/Code&gt; &lt;/X&gt; &lt;X&gt; &lt;Code&gt;DEF&lt;/Code&gt; &lt;/X&gt; &lt;/Z&gt;"); var codeValues = document.XPathSelectElements("//Z/X/Code") .Select(e =&gt; e.Value) .OrderByDescending(e =&gt; e); </code></pre> <p>You can simplify it even further if you want. You need to take into account performance though. If your xml files are large this won't perform as well I guess. If you only have small files the simplicity of this outweighs the small performance penalty. </p>