title: Handling selectSingleNode(Xpath) in XML/Soap envelope having elements with same prefix and multiple uri
body: <p>I have a Soap packet  with same prefix ns2 for multiple uri: <a href="http://schemas.datacontract.org/2004/07/TestServices" rel="nofollow">http://schemas.datacontract.org/2004/07/TestServices</a>, <a href="http://schemas.datacontract.org/2004/07/TestServices.DTO" rel="nofollow">http://schemas.datacontract.org/2004/07/TestServices.DTO</a>.</p>
  
  <p>When I am trying to set value in XDoc using xDoc.SelectSingleNode(xPath, oManager).InnerXml , it is giving null because of multiple uri conflict. Is there any way to dynamically hanlde this? I cannot do any changes in xpath as it is coming from different services with different format. My namespace manager code is as follows:</p>
  
  <pre><code>public static XmlNamespaceManager getAllNamespaces(XmlDocument xDoc)
          {
              XmlNamespaceManager result = new XmlNamespaceManager(xDoc.NameTable);
  
              IDictionary&lt;string, string&gt; localNamespaces = null;
              XPathNavigator xNav = xDoc.CreateNavigator();
              while (xNav.MoveToFollowing(XPathNodeType.Element))
              {
                  localNamespaces = xNav.GetNamespacesInScope(XmlNamespaceScope.Local);
                  foreach (var localNamespace in localNamespaces)
                  {
                      string prefix = localNamespace.Key;
                      if (string.IsNullOrEmpty(prefix))
                          prefix = "DEFAULT";
                      result.AddNamespace(prefix, localNamespace.Value);
                  }
              }
  
              return result;
          }
  
  foreach (Telerik.WinControls.UI.RadTreeNode tn in treeView.SelectedNode.Nodes)
     {
        if (tn.Text == r.Cells[0].Value.ToString())
               {
          string xPath = tn.FullPath;
          xPath = "//" + xPath.Replace(@"\", "/").Replace(" ", "");
          if (!(r.Cells[2].Value.ToString().StartsWith("&lt;") &amp;&amp; r.Cells[2].Value.ToString().EndsWith("&gt;")) &amp;&amp; !(r.Cells[2].Value.ToString().StartsWith("[") &amp;&amp; r.Cells[2].Value.ToString().EndsWith("]")))
          {                                                   
              xDoc.SelectSingleNode(xPath, oManager).InnerXml = r.Cells[2].Value.ToString();
  
              }
           }
     }
  </code></pre>
  
  <p>My soap envelope is as follows:</p>
  
  <pre><code>&lt;s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'&gt;
    &lt;s11:Body&gt;
      &lt;ns1:AccountCreation xmlns:ns1='www.test.com'&gt;
        &lt;ns1:Data&gt;
          &lt;ns2:LoginUser xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices'&gt;?XXX?&lt;/ns2:LoginUser&gt;
          &lt;ns2:UserPassword xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices'&gt;?XXX?&lt;/ns2:UserPassword&gt;
          &lt;ns2:IPAddress xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices'&gt;?XXX?&lt;/ns2:IPAddress&gt;
          &lt;ns2:ProductID xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices.DTO'&gt;?999?&lt;/ns2:ProductID&gt;
          &lt;ns2:BusinessAccountNumber xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices.DTO'&gt;?999.99?&lt;/ns2:BusinessAccountNumber&gt;
          &lt;ns2:StoreName xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices.DTO'&gt;?XXX?&lt;/ns2:StoreName&gt;
          &lt;ns2:Title xmlns:ns2='http://schemas.datacontract.org/2004/07/TestServices.DTO'&gt;?XXX?&lt;/ns2:Title&gt;
        &lt;/ns1:Data&gt;
      &lt;/ns1:AccountCreation&gt;
    &lt;/s11:Body&gt;
  &lt;/s11:Envelope&gt;
  </code></pre>