XmlException: The data at the root level is invalid….
XmlException: The data at the root level is invalid. Line 1, position 1.
This might be a really obscure (or dumb?) ASP.NET / C# problem, but again I thought I’d post something about it in case it helps someone else searching about this issue….
I was getting an exception when loading an XML file:
Error with … xmlnav.xml: System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1.
Using the following code:
Searching for others’ advice / solutions for such a problem on the web didn’t help very much… it kept happening no matter what I was trying.
Turned out the problem was very very simple to fix (as they sometimes are) – it was just a typo. The variable “xml” was a full file path to an xml FILE I was trying to load, and silly me, you have to use docXml.Load() to load an xml FILE, not docXml.LoadXml() – the typo must have gotten in there from a poor use of VS.NET Intellisense or something (auto-completing LoadXml instead of just Load) – doh!
Changing the code to:
Worked just fine (of course).
Like I mentioned, just in case this helps someone else!
2 phản hồi »
Bài viết mới nhất
Ý kiến mới nhất
niah on Một cô gái 17 tuổi thông báo v… Nihit on XmlException: The data at the… Kranthi on How To: Encrypt Configuration… Dhaval on XmlException: The data at the… Nguyễn Sơn on eRec search
- 19,846 lượt xem
Gửi tin nhắnadfsdfdasfsf sadf as df asd f
Site infoIncomplete Leo
Tạo một website miễn phí hoặc 1 blog với WordPress.com.