title: How to check if a value already exists in an xml file using linq
body: <p>Although there are many answers  to this topic, I couldn't find one that worked in my case.
  The app opens the xml file to add new entries from a list, but prevents duplicates. I don't know how to check (using Linq) if the item is already in the xml </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- XML File sample --&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Items&gt;
   &lt;Item&gt;
      &lt;Text&gt;AUDI&lt;/Text&gt;
    &lt;/Item&gt;
  &lt;Item&gt;
    &lt;Text&gt;BMW&lt;/Text&gt;
  &lt;/Item&gt;
  &lt;/Items&gt;
  </code></pre>
  
  <p>and this is the code. (I left out trim, uppercase, etc for simplicity) 
  The problem is in the result var, it always return false.</p>
  
  <pre><code>XDocument doc = XDocument.Load(@filePath);
  for (int i = 0; i &lt; items.Count; i++)
    {
       var result = doc.Descendants("Item").Any(x =&gt; x.Element("Text").ToString().Equals(items[i]);
  
       if (! result)
            {
  
            }
  
  doc.Save(@filePath);
  </code></pre>