System.Xml.XmlException: ‘Data at the root level is invalid. Line 1, position 1.’
I get an ‘System.Xml.XmlException: ‘Data at the root level is invalid. Line 1, position 1.» error.
How can I fix the issue? Why is it checking for xml when the data is retuned as json?
I am using Micorsoft OData Connected Service to generate classes and plumbing for OData client.
var serviceRoot = "http://localhost:65202/api/odata/"; var context = new Container(new Uri(serviceRoot)); context.BuildingRequest += Context_BuildingRequest; var clients = context.Clients.Where(c => c.ID >= 0 & c.ID p.ID) .Select(c => new < c.Company, c.ID >); foreach (var client1 in clients) < Console.WriteLine("", client1.Company, client1.ID); >
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Data at the root level is invalid [duplicate]
Note: although this question is older than the question I just closed it as a duplicate of, the later question is more to the point. In particular, it doesn’t cloud the issue by using HttpContext .
Jul 23, 2014 at 2:39
I just had this error on a resx file in Visual Studio and it was resolved by closing Visual Studio and opening it again.
Nov 28, 2017 at 11:38
Check the web.config, I had an invalid character at the start of it.
Feb 19, 2020 at 9:49
The dupe direction should be reversed on this. This one is older and has more answers covering more cases, in addition to the correct answer which the other one also has.
Dec 15, 2021 at 16:55
3 Answers 3
doc.LoadXml(HttpContext.Current.Server.MapPath("officeList.xml"));
doc.Load(HttpContext.Current.Server.MapPath("officeList.xml"));
LoadXml() is for loading an XML string, not a file name.
answered Apr 21, 2011 at 19:12
BrokenGlass BrokenGlass
160k 28 28 gold badges 291 291 silver badges 338 338 bronze badges
The last line helped me, I was facing a data root error but had no idea as was loading the configuration file from a project so I used xmlDoc.Load(filePath) and it worked. Thanks!
Sep 16, 2021 at 11:33
XmlDocument.LoadXml() loads an XML string XmlDocument.Load() loads XML file
Sep 16, 2021 at 11:58
«Data at the root level is invalid» means that you have attempted to parse something that is not an XML document. It doesn’t even start to look like an XML document. It usually means just what you found: you’re parsing something like the string «C:\inetpub\wwwroot\mysite\officelist.xml».
community wiki
. or something that starts with an xml document specification line as usual that definitely looks like an xml document to us, but not for XmlDocument.LoadXml(), see the comment by Joseph Morgan?>
Aug 21, 2014 at 16:53
I found that the example I was using had an xml document specification on the first line. I was using a stylesheet I got at this blog entry and the first line was
which was causing the error. When I removed that line, so that the stylesheet started with the line
my transform worked. By the way, that blog post was the first good, easy-to follow example I have found for trying to get information from the XML definition of an SSIS package, but I did have to modify the paths in the example for my SSIS 2008 packages, so you might too. I also created a version to extract the «flow» from the precedence constraints. My final one looks like this:
From,To~ , ~
and gave me a CSV with the tilde as my line delimiter. I replaced that with a line feed in my text editor then imported into excel to get a with look at the data flow in the package.
whoa there, pardner!
Your request has been blocked due to a network policy.
Try logging in or creating an account here to get back to browsing.
If you’re running a script or application, please register or sign in with your developer credentials here. Additionally make sure your User-Agent is not empty and is something unique and descriptive and try again. if you’re supplying an alternate User-Agent string, try changing back to default as that can sometimes result in a block.
You can read Reddit’s Terms of Service here.
if you think that we’ve incorrectly blocked you or you would like to discuss easier ways to get the data you want, please file a ticket here.
when contacting us, please include your ip address which is: 95.214.216.211 and reddit account
Data at the root level is invalid
We have closed this ticket because another page addresses its subject:
Modified 0—> Category: / 0—> Tags:
Related Tickets
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided «as is» without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confindential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Recently viewed tickets
You have yet to view any tickets.
Your search criteria do not match any tickets.
A server error occurred while processing your request. Please try again at a later time.
Frequently Asked Questions
Windows Desktop Controls
Enterprise & Server Tools
Mobile Controls
Web Controls
Frameworks & Productivity
Testing & QA
Support & Documentation
DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, Delphi, HTML5 or iOS & Android development. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.
We are here to help. Should you have any questions or need assistance from a member of our team, write to us at info@devexpress.com.
Use of this site constitutes acceptance of our Website Terms of Use and Privacy Policy (Updated). Cookies Settings
Copyright © 1998-2024 Developer Express Inc. All trademarks or registered trademarks are property of their respective owners