I am using XDocument and XElement to read the XML. While running the website from visual studio 2012 there is no problem in reading. After publishing i am getting "Root element is missing" exception.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: Root element is missing.
Please find the XML below
<CTReport>
<ReportHeader>
<UserID>1508ac07-0070-46b9-84f4-533b83cb3770</UserID>
</ReportHeader>
<ReportInfoToDisplay>
<Report PlaceHolder="7">
<Info Name="Average Mix report" TranslatedText="" ShowPrice="1" />
<ReportControls>
<ControlInfo Type="Date" Name="Date" TranslatedText="" Data="!" />
<ControlInfo Type="Lookup" Name="Scale operator" TranslatedText="" Data="" />
<ControlInfo Type="Lookup" Name="Display Jobs of" TranslatedText="" Data="Normal!Layaway!" />
<ControlInfo Type="Combo" Name="SortBy" TranslatedText="SortBy" Data="Sort by mixer + product group!Sort by product group" />
</ReportControls>
</Report>
<Report />
<Report PlaceHolder="8">
<Info Name="Mix report" TranslatedText="" ShowPrice="0" />
<ReportControls>
<ControlInfo Type="Date" Name="Date" TranslatedText="" Data="!" />
<ControlInfo Type="Lookup" Name="Scale operator" TranslatedText="" Data="" />
<ControlInfo Type="Combo" Name="SortBy" TranslatedText="SortBy" Data="Sort by mixer + product group!Sort by product group" />
</ReportControls>
</Report>
<Report PlaceHolder="9">
<Info Name="Scale report" TranslatedText="" ShowPrice="0" />
<ReportControls>
<ControlInfo Type="Date" Name="Date" TranslatedText="" Data="!" />
<ControlInfo Type="String" Name="Job reference" TranslatedText="" Data="" />
<ControlInfo Type="String" Name="Job ID" TranslatedText="" Data="" />
<ControlInfo Type="Lookup" Name="Scale operator" TranslatedText="" Data="" />
</ReportControls>
</Report>
</ReportInfoToDisplay>
</CTReport>
Code:
XDocument xml = XDocument.Parse(reportXML);
reportXML is string.
Please note while XDocument is created from XML file there is no exception