XML file as input to LoadXml returns xml exception c#
<p>In my unit testing project, I have merged all my xml files into single xml file and need to send to webservice to seperate it into modules.</p>

<p>So, I have used the below code in my webservice,</p>

<pre><code>//xmlString is my xml file content

try
{
    XElement XmlDocument = new XElement("XMLDocument");
    XmlDocument testDoc = new XmlDocument();
    testDoc.LoadXml(xmlString);
    XmlDocument = XElement.Load(new XmlNodeReader(testDoc));
}
catch (Exception ex)
{
    string returnString = ex.StackTrace.ToString();

    returnString += "XML breaks the code";

    return returnString;
}
</code></pre>

<p><strong>EDIT: While running this in finalbuilder, I am getting below exception</strong></p>

<blockquote>
  <p><strong>Exception Message:    at ModuleSeparator.GetDetails(String xmlString) System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.</strong></p>
  
  <p>Results
      Return value of 'ModuleSeparator' :    at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
         at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
         at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
         at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
         at System.Xml.XmlDocument.Load(XmlReader reader)
         at System.Xml.XmlDocument.LoadXml(String xml)
         at ModuleSeparator.GetDetails(String xmlString)XML breaks the code
      Setting variable 'ModuleWiseTestCaseResults' to value '   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
         at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
         at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
         at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
         at System.Xml.XmlDocument.Load(XmlReader reader)
         at System.Xml.XmlDocument.LoadXml(String xml)
         at ModuleSeparator.GetDetails(String xmlString)XML breaks the code'.</p>
</blockquote>

<p><strong>My XML will look like,</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;test-results name="Merged results" total="418" errors="0" failures="0" not-run="0" inconclusive="128" ignored="0" skipped="7" invalid="0" date="2016-03-08" time="10:47:33"&gt;
    &lt;test-suite type="Test Project" name="" executed="True" result="Skipped" success="True" time="311.143731" asserts="0"&gt;
        &lt;results&gt;&lt;/results&gt;
    &lt;/test-suite&gt;
&lt;/test-results&gt;
</code></pre>