title: How to get the sibling of an xml node
body: <p>I have an xml file as below</p>
  
  <pre><code>&lt;Games&gt;
     &lt;Game&gt;
        &lt;name&gt;Tzoker&lt;/name&gt;
        &lt;file&gt;tzoker1&lt;/file&gt;
     &lt;/Game&gt;
     &lt;Game&gt;
        &lt;file&gt;lotto770&lt;/file&gt;
     &lt;/Game&gt;
     &lt;Game&gt;
        &lt;name&gt;Proto&lt;/name&gt;
        &lt;file&gt;proto220&lt;/file&gt;
     &lt;/Game&gt;
  &lt;/Games&gt;
  </code></pre>
  
  <p>I want to get the values of name and file items for every Game node.
  It is easy by using this query.</p>
  
  <pre><code>string query = String.Format("//Games/Game");
   XmlNodeList elements1 = xml.SelectNodes(query);
   foreach (XmlNode xn in elements1)
   {
     s1 = xn["name"].InnerText;
     s2 = xn["file"].InnerText;
   }
  </code></pre>
  
  <p>The problem is that there are some nodes that they don't have the name item. So the code above doesn't work.
  I have solved the problem by using the following code</p>
  
  <pre><code>string query = String.Format("//Games/Game/name");
  XmlNodeList elements1 = xml.SelectNodes(query);
  foreach (XmlNode xn in elements1)
  {
    s1 = xn.InnerText;
    string query1 = String.Format("//Games/Game[name='{0}']/file", s1);
    XmlNodeList elements2 = xml.SelectNodes(query1);
    foreach (XmlNode xn2 in elements2)
    {
      s2 = xn2.InnerText;
    }
  }
  </code></pre>
  
  <p>The problem is that there is a case that two or more nodes have the same name value. So, the s2 variable will get the file value of the last node that the loop finds. So, I would like to find a way to get the sibling file value of the current name item. How could I do it? I try do move to the parent node of the current node and then to move to the file item but without success by using the following code.</p>
  
  <pre><code>string query = String.Format("//Games/Game/name");
  XmlNodeList elements1 = xml.SelectNodes(query);
  foreach (XmlNode xn in elements1)
  {
     s1 = xn.InnerText;
     string query1 = String.Format("../file");
     XmlNodeList elements2 = xml.SelectNodes(query1);
     foreach (XmlNode xn2 in elements2)
     {
       s2 = xn2.InnerText;
     }
  }
  </code></pre>
  
  <p>I hope there is a solution.</p>