title: Duplicate values in Xml database
body: <p>I need to insert only unique values in my XML database based on the "userName" value. For example there can't be two players which has same name in the database. The implementation of my xml database which is named as "MyXML.xml" is like that :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
        &lt;Players&gt;
           &lt;player name="cag" score="5555" /&gt;
           &lt;player name="cihan" score="1222" /&gt;
           &lt;player name="can" score="333" /&gt;
       &lt;/Players&gt;
  </code></pre>
  
  <p>and my related code in order to detetect duplication is:</p>
  
  <pre><code>      public bool insertUserDetails(string userName,float userScore){
  
  
             XDocument doc = Document.Load(HttpContext.Current.Server.MapPath("MyXML.xml"));
  
             var duplicate = doc.Element("Players").Elements("player").Where(x =&gt;(string)x.Value == userName).SingleOrDefault();
  
             if (duplicate != null){
  
                 return false;
  
            }
            else{
                 return true;
           }
       }
  </code></pre>
  
  <p>when I try to insert a duplicate value for example "can" and "333",  var duplicate value turns out to be null. How can I fix this problem ?</p>