473,574 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
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 16572
8,658 Recognized Expert Moderator Expert
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
3 New Member
I did not get.What is BOM?
Aug 25 '09 #3
8,658 Recognized Expert Moderator Expert
ask Mr. Wikipedia

Aug 25 '09 #4
3 New Member
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
8,658 Recognized Expert Moderator Expert
@vinaykumarrajpo ot
do I? well, I can make sense of the code…

@vinaykumarrajpo ot
nope, don’t know anything about C# ( C#? ;)
Aug 25 '09 #6
1 New Member
try this:
docxml.Load(myX mlString);
Sep 18 '09 #7

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

Similar topics

by: Korivo | last post by:
Im getting this error while trying to read a xml file that i receive from a POST heres the code: Dim MyXmlReader As XmlTextReader Dim strNodeResult As String Dim NodeType As XmlNodeType Dim objwriter As StreamWriter
by: Alan Wang | last post by:
Hi there, I got this message ("The data at the root level is invalid. Line 1, position 1.") when I moved the application from my workstation to Windows 2003 web server. But the wired thing the whole application works fine on my workstation which running Windows xp prof sp 2 edition. Please help me out Thanks
by: MR | last post by:
I get the following Exception "The data at the root level is invalid. Line 1, position 642" whenever I try to deserialize an incoming SOAP message. The incoming message is formed well and its length is 642 bytes ( I have appended it to the end of this message). I suspect that the reason may have something to do with an incorrect declaration...
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. Asset List is a long array of AssetIds. I declare it as: Dim AssetList(0) As Long AssetList(0) = 47288 Now, I pass an array of AssetIDs as long from here into the following line: doc.LoadXml(EDP.ExportPositions(g_SessionID, cmbStartDateandTime.Text, cmbEndDateandTime.Text, AssetList).ToString) as per the
by: =?Utf-8?B?am1ncm8=?= | last post by:
I created a web service in visual studio 2003, tested it with a sample.xml file from a vendor we are using, and it worked exactly like it should. I depoloyed it to our server, created a project calling the webservice with the sample.xml file, and again it worked. Now the vendor is calling the web service from their application and receiving...
by: paulnamroud | last post by:
Hi all, I wrote a stored procedure with ms sql 2005 which returns a string parameter. This parameter contains differents xml elements and it's well formated. First, its works fine when i call my stored procedure with asp 3.0. I can display all the contents of this xml parameter with xsl. But, when it comes to call this stored procedure...
by: johnsonkt | last post by:
hi all , when m trying to validate my xml using xsd file it gives me the following error "Data at the root level is invalid. Line 1, position 1" i tried to open the XML file using IE and there are no errors and there are no blank space before the root element.the xml is created dynamically and it is send as a string to validate. the...
by: ayemyat | last post by:
Hi All, I have a remoting service which consumes the web service in another server. I have the following exception throw by the web service. System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1. There is an error in XML document (0, 0). &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;MSVBalanceEnquiry...
by: Cirene | last post by:
My ASP.NET project builds fine (VS2008). I added a new web deployment project. When I try to build it I get: Data at the root level is invalid. Line1, position 1. (The file is web.config, line 1, column 1, in my deploy project.) I double click on the error and it shows this... vti_encoding:SR|utf8-nl vti_timelastmodified:TR|09 May...
by: Hamayun Khan | last post by:
Hi I get the following error Server Error in '/teachnetwork' Application. -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.