title: How to create XmlNodes structure based on certain pre-condition
body: <p>What I'm trying to do is create an XmlNode at a specific path if it doesn't exist.</p>
  
  <p>My function looks like this:</p>
  
  <pre><code>public XmlElement getElement(string path) 
  {
      XmlElement result = (XmlElement)document.SelectSingleNode(path);
      if (result == null) {
          // TODO: Create the specified path here
      }
      return result;
  }
  </code></pre>
  
  <p>Is there any built-in function I can use to create the element at the specified path? The path might contain attributes like this <code>/root/element[@id="5"]/subelement/item[@name="thing"]</code>.</p>
  
  <p>Thanks in advance!</p>