title: Append an XML element list
body: <p>I'm trying to reformat my XML code so it's easier to read. At the moment it looks like this:</p>
  
  <pre><code> &lt;Settings&gt;
    &lt;Display_Settings&gt;
      &lt;ScreenName Name="1"&gt;1&lt;/ScreenName&gt;
      &lt;ScreenTag Tag="1"&gt;1&lt;/ScreenTag&gt;
      &lt;LocalPosition X="1" Y="1" Z="1"&gt;0.000, 0.000, 0.000&lt;/LocalPosition&gt;
      &lt;Width Width="0.000"&gt;0.000&lt;/Width&gt;
      &lt;Height Height="0.000"&gt;0.000&lt;/Height&gt;
    &lt;/Display_Settings&gt;
  &lt;/Settings&gt;
  </code></pre>
  
  <p>However what I want it look like is this:</p>
  
  <pre><code> &lt;Settings&gt;
        &lt;Display_Settings&gt;
          &lt;ScreenName Name="1"&gt;1
                   &lt;ScreenTag Tag="1"&gt;1&lt;/ScreenTag&gt;
                   &lt;LocalPosition X="1" Y="1" Z="1"&gt;0.000, 0.000, 0.000&lt;/LocalPosition&gt;
                   &lt;Width Width="0.000"&gt;0.000&lt;/Width&gt;
                   &lt;Height Height="0.000"&gt;0.000&lt;/Height&gt;
          &lt;/ScreenName&gt;
        &lt;/Display_Settings&gt;
   &lt;/Settings&gt;
  </code></pre>
  
  <p>Ok, rubbish example but I hope you get the jist; I want all of my values like tag and local position etc to be a child of the screen name. Now I know that to do this it would normally be the following call:</p>
  
  <pre><code> XmlNode _rootNode; // in the above i'll have set this to be Display_Settings
   _rootNode.AppendChild(_screenTag);
  </code></pre>
  
  <p>But, I've set my XML creation code in a list that is held in one class and populated in another. It looks like this: </p>
  
  <p>Generate XML</p>
  
  <pre><code>  public HV_WriteXML()
      {
          //root node
          _rootNode = _xmlDoc.CreateElement("InMo_Settings");
          _xmlDoc.AppendChild(_rootNode);
  
          _userNode = _xmlDoc.CreateElement("Display_Settings");
          _rootNode.AppendChild(_userNode);
      }
  
      public void GenereateSettingsFile(List&lt;Node&gt; nodeList, string filePath)
      {
  
          _rootNode.RemoveChild(_userNode);
  
          _userNode = _xmlDoc.CreateElement("Display_Settings");
          _rootNode.AppendChild(_userNode);
  
          foreach (Node n in nodeList)
          {
              foreach (XmlElement e in n.GenerateXML(_xmlDoc))
              {
                  _userNode.AppendChild(e);
              }
          }
          _xmlDoc.Save(filePath);
      }
  </code></pre>
  
  <p>Then to fill this out, I'm doing the following in a derived class:</p>
  
  <pre><code>  public override List&lt;XmlElement&gt; GenerateXML(XmlDocument _xmlDoc)
      {
          List&lt;XmlElement&gt; elementList = new List&lt;XmlElement&gt;();
  
  
  
           if (nodeDictionary.ContainsKey("Name "))
           {
              XmlElement _screenName = _xmlDoc.CreateElement("ScreenName");
              _screenName.SetAttribute("Name", (string)nodeDictionary["Name "].value);
              _screenName.InnerText = (string)nodeDictionary["Name "].value;
              elementList.Add(_screenName);
           }
  
          if (nodeDictionary.ContainsKey("Tag"))
          {
              XmlElement _screenTag = _xmlDoc.CreateElement("ScreenTag");
              _screenTag.SetAttribute("Tag", (string)nodeDictionary["Tag"].value);
              _screenTag.InnerText = (string)nodeDictionary["Tag"].value;
  
              elementList.Add(_screenTag);
          }
  </code></pre>
  
  <p>}</p>
  
  <p>Now my real question is how do I append my _screenTag element so that its a child of my screen name when I've set up the creation of my xml in a list in a different class?</p>