title: XPathSelectElement is very slow; is there a better way to get a value given an XPath?
body: <p>I have a file that essentially a list of XPaths like so:</p>
  
  <pre><code>/Options/File[1]/Settings[1]/Type[1]
  /Options/File[1]/Settings[1]/Path[1]
  /Options/File[1]/Settings[2]/Type[1]
  /Options/File[1]/Settings[2]/Path[1]
  /Options/File[2]/Settings[1]/Type[1]
  /Options/File[2]/Settings[1]/Path[1]
  </code></pre>
  
  <p>I need to grab the values from the elements pointed to from these XPaths in moderate sized XML file (~3-5MB). Using XPathSelectElement works well, but is extremely slow. Is there a quicker way to do the same with Linq to XML or even manually traversing the XML? </p>
  
  <p>In a related question, is the index value in the XPath and the order of elements returned from an XElement guarenteed to be the same? For instance, will these return the same:</p>
  
  <pre><code>xdoc.XPathSelectElement("/Options/File[1]/Settings[2]);
  
  xdoc.root.Elements("File").ElementAt(0).Elements("Settings").ElementAt(1);
  </code></pre>