title: How to add elements or nodes, to existing XML, given an input string to compare with - using a LINQ query
body: <p>I am looking for a solution using a 1-stmt LINQ query instead. 
  I have an input string that is technically the person's name, if this  is not already in the XML given, I need to update the XML with this  added.</p>
  
  <p>I'm able to query 2 XMLs easily, but not XML and this name-string (it looks at it character-wise, not as a whole string). Maybe some kind of conversion may help? I could also wrap this string into an XML if it makes the query simpler to write.</p>
  
  <p>Here is the approach to explain what I desire to achieve in the LINQ query, without using the messy foreach/ifs like below: 
  XML1:</p>
  
  <pre><code>        /*      &lt;classes&gt;
           *          &lt;set&gt;
           *              &lt;name&gt;Students&lt;/name&gt;
           *                  &lt;Person&gt;
           *                          &lt;PID&gt;1&lt;/PID&gt;
           *                          &lt;Val&gt;Jack&lt;/Val&gt;
           *                      &lt;/Person&gt;
           *                      &lt;Person&gt;
           *                          &lt;PID&gt;2&lt;/PID&gt;
           *                          &lt;Val&gt;Jill&lt;/Val&gt;
                                  &lt;/Person&gt;
           *                  &lt;/set&gt;
           *                &lt;/classes&gt;
           */
      XDocument listOfChild = XDocument.Parse("&lt;aboveXML/&gt;");
      string ipString = "Value2";
      bool childExists = false;
      XElement addChild = null;
      if (!String.IsNullOrEmpty(ipString))
      {
  
          foreach (var tag in listOfChild.Descendants("Person"))
              if (tag.Element("Val").Value.ToLower() == ipString.ToLower()) 
              {
                  childExists = true;
                  break;
              }
  
          if (!childExists)
          {
              addChild = new XElement("Person",
                                   new XElement("PID", -1),
                                   new XElement("Val", ipString)
                                       );
          }
      }
      XElement el1 = listOfChild.Root.Descendants("set").FirstOrDefault(); 
      el1.Add(addChild);
  </code></pre>