How i can write xml node in C#
<p>i want to write text in xml file under tag "Engine" but right now it can write under tag "Service"  here is my code</p>

<pre><code>        XmlDocument doc = new XmlDocument();
        doc.Load(filename);
        XmlElement root = doc.DocumentElement;
        XmlNodeList elemList = root.GetElementsByTagName("Engine");
            for (int i = 0; i &lt; elemList.Count; i++)

            {
                XmlNode head = doc.CreateNode(XmlNodeType.Element, "Host", null);
                XmlAttribute na = doc.CreateAttribute("name");
                na.Value = "url";

                XmlNode nodeTitle = doc.CreateElement("Valve");
                XmlAttribute className = doc.CreateAttribute("className");
                className.Value = "org.apache.catalina.valves.AccessLogValve";

                doc.DocumentElement.LastChild.AppendChild(head);
                doc.Save(filename); 
            }
</code></pre>

<p>here is xml file</p>

<pre><code> &lt;Server&gt;
      &lt;Service name="Catalina"&gt;
          &lt;Engine name="Catalina" &gt;
            &lt;Host name="localhost"&gt;
              &lt;Valve  /&gt;
            &lt;/Host&gt;
          &lt;/Engine&gt;
      &lt;/Service&gt;
 &lt;/Server&gt;
</code></pre>