469,270 Members | 1,118 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Data at the root level is invalid. Line 1, position 1'

xml file is

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Books>
  3.     <Book id="1">
  4.         <Author>Mark</Author>
  5.         <Publisher>Sams</Publisher>
  6.     </Book>
  7. </Books>
Code Behind is

Expand|Select|Wrap|Line Numbers
  1. string myXmlString="D:\books.xml";
  2.         XmlDocument docxml = new XmlDocument();
  3.         docxml.LoadXml(myXmlString);
  4.         XmlNodeList xmlist = docxml.SelectNodes("Books/Book");
  5.         foreach (XmlNode xn in xmlist)
  6.         {
  7.             Uname.Text = xn["Author"].InnerText;
  8.         }
Aug 25 '09 #1
6 16394
Dormilich
8,651 Expert Mod 8TB
the XML code posted is correct. you may check the LoadXml() function, whether it accepts the XML Prolog. other than that you may have a BOM (Byte Order Mark) at the beginning of your file, which can cause problems.
Aug 25 '09 #2
I did not get.What is BOM?
Aug 25 '09 #3
Dormilich
8,651 Expert Mod 8TB
ask Mr. Wikipedia


.........
Aug 25 '09 #4
Leave BOM....
You know what I m trying to do....
Do you have any other code to solve this...I need it help plz
Aug 25 '09 #5
Dormilich
8,651 Expert Mod 8TB
@vinaykumarrajpoot
do I? well, I can make sense of the code…

@vinaykumarrajpoot
nope, don’t know anything about C# ( C#? ;)
Aug 25 '09 #6
try this:
docxml.Load(myXmlString);
Sep 18 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by XML newbie: Urgent pls help! | last post: by
2 posts views Thread by =?Utf-8?B?am1ncm8=?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.