title: How to check if xml file is empty or not using c#
body: <p>Hello everyone I want to  check my xml file if it is empty or not. I am trying to update one xml data to another for this I am using the following code.Now Please tell me  how can I check if my xml file has data or not 
  Here is the code I am using for update my xml file </p>
  
  <pre><code>protected void CheckUpdates()
  {
      StringReader strReader = new StringReader("..\\xml\\Updatelist.xml");
      XmlReader reader = XmlReader.Create(strReader);
      try
      {
         while (reader.Read())
         {
             var originalXmlDoc = XDocument.Load("..\\xml\\list.xml"); var newXmlDoc = XDocument.Load("..\\xml\\Updatelist.xml");
  
             foreach (var newElement in newXmlDoc.Element("blocker").Elements("lst"))
             {
                 newElement.Value.Trim();
                 if (!originalXmlDoc.Element("blocker").Elements("lst")
                         .Any(oldElement =&gt; oldElement.Value.Trim().Equals(
                         newElement.Value.Trim(),
                         StringComparison.InvariantCultureIgnoreCase)))
                  {
                     originalXmlDoc.Element("blocker").Add(new XElement("lst", newElement.Value));
                  }
               }
               originalXmlDoc.Save("..\\xml\\list.xml", SaveOptions.None);
  
               XmlDocument doc = new XmlDocument();
               doc.Load("..\\xml\\Updatelist.xml");
               doc.DocumentElement.RemoveAll();
               doc.Save("..\\xml\\Updatelist.xml");
            }
         }
      catch (XmlException ex)
      {
         //Catch xml exception
         //in your case: root element is missing
      }
  }
  </code></pre>
  
  <p>I am Getting this error </p>
  
  <blockquote>
    <p>Data at the root level is invalid. Line 1, position 1.</p>
  </blockquote>
  
  <p>Please tell me how can I check if my <code>Updatelist.xml</code> is empty or not?</p>
  
  <p>Now I get this error </p>