title: If: XElement Exists, Else Create new one
body: <p>My XML File:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;SimpleKD&gt;
    &lt;player name="Tardis"&gt;
      &lt;kills&gt;0&lt;/kills&gt;
      &lt;deaths&gt;0&lt;/deaths&gt;
      &lt;/player&gt;
  &lt;/SimpleKD&gt;
  </code></pre>
  
  <p>First off, I need to check if the username "Tardis" exists in the xml <code>.element("player").attribute("name")</code>.</p>
  
  <p>If it doesn't, i need to create it with kills and deaths at zero.
  If it does, I need to read kills and deaths and set them to variables.</p>
  
  <p>I have been using <code>XElement</code> to try and do this.. Thanks!</p>
  
  <p>Code used to write the XML:</p>
  
  <pre><code>public static string username = "Tardis";
  public static int kills = 0;
  public static int deaths = 0;
  
  ........
  
  XElement Players = new XElement(
                        "SimpleKD",
                        new XElement("player",
                            new XAttribute("name", username),
                        new XElement("kills", kills),
                        new XElement("deaths", deaths)));
  </code></pre>