title: How to reference an XML element nested within an unknown amount of other elements
body: <p>I want to reference an XML element that is nested within an unknown amount of other elements. <br/>
  For example, if I have an XML file like this:</p>
  
  <pre><code>&lt;root&gt;
      &lt;Example&gt;
      &lt;/Example&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And I want to add an element within the <code>&lt;Example&gt;</code> element. When I add an element within the root element I can do it like this (assuming <code>Doc</code> is an already defined XDocument):</p>
  
  <pre><code>Doc.Element("root").Add(new XElement("Example"));
  </code></pre>
  
  <p>And if there are two, I can do:</p>
  
  <pre><code>Doc.Element("root").Element("Example").Add(new XElement("newExample"))
  </code></pre>
  
  <p>This works fine if I know exactly what elements are going to be within what, because I can hard code it. This does not work, however, when I don't know what elements are going to be in what. <br/> <br/></p>
  
  <p>My project is a virtual folder system (makes more sense if you read <a href="https://github.com/CobaltsDev/Virtual-Folder-System/wiki" rel="nofollow noreferrer">this</a>), so I don't know what elements will be nested within what. I have thought of saving the directory within the program in a <code>List&lt;string&gt;</code>, which works to store the directory, but because the only way I know how to reference elements is with hard coding every single element. Is there a way I can reference any element nested within any other element without having to hard code every parent element so I can use methods like XElement.Add()?</p>