473,781 Members | 2,732 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
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 dynamically generated xml string is the following.

<?xml version="1.0" encoding="utf-8" ?>
<MessageEntit y xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<Email retryattempts=" 1">
<Message>
<From>Notificat ionEmail</From>
<Recipients>
<Recipient recipientid="em ail@gmail.com" retryattempts=" 1" templateid="0" subject="email" />
</Recipients>
<Subject>emai l</Subject>
<Body>hi this is email body</Body>
<TemplateId>0 </TemplateId>
</Message>
</Email>
<Sms retryattempts=" 0">
<Message>
<From>Notificat ionsms</From>
<Recipients>
<Recipient recipientid="99 86267364" retryattempts=" 0" templateid="0" subject="SMS" />
</Recipients>
<Subject>SMS</Subject>
<Body>sms message</Body>
<TemplateId>0 </TemplateId>
</Message>
</Sms>
</MessageEntity>


and the schema file is the following.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDe fault="unqualif ied" elementFormDefa ult="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Notificat ion">
<xs:complexType >
<xs:sequence>
<xs:element name="Email">
<xs:complexType >
<xs:sequence>
<xs:element name="Message">
<xs:complexType >
<xs:sequence>
<xs:element name="From" />
<xs:element name="Recipient s">
<xs:complexType >
<xs:sequence>
<xs:element name="Recipient ">
<xs:complexType >
<xs:simpleConte nt>
<xs:extension base="xs:string ">
<xs:attribute name="recipient id" type="xs:string " use="required" />
<xs:attribute name="retryatte mpts" type="xs:string " use="required" />
<xs:attribute name="templatei d" type="xs:string " use="required" />
<xs:attribute name="subject" type="xs:string " use="required" />
</xs:extension>
</xs:simpleConten t>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateI d" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryatte mpts" type="xs:string " use="required" />
</xs:complexType>
</xs:element>
<xs:element name="Sms">
<xs:complexType >
<xs:sequence>
<xs:element name="Message">
<xs:complexType >
<xs:sequence>
<xs:element name="From" />
<xs:element name="Recipient s">
<xs:complexType >
<xs:sequence>
<xs:element name="Recipient ">
<xs:complexType >
<xs:simpleConte nt>
<xs:extension base="xs:string ">
<xs:attribute name="recipient id" type="xs:string " use="required" />
<xs:attribute name="retryatte mpts" type="xs:string " use="required" />
<xs:attribute name="templatei d" type="xs:string " use="required" />
<xs:attribute name="subject" type="xs:string " use="required" />
</xs:extension>
</xs:simpleConten t>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateI d" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryatte mpts" type="xs:string " use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


can anyone help me plz...
regards,
John
Aug 29 '07 #1
4 8169
MarkoKlacar
296 Recognized Expert Contributor
Hi,

you have to follow your XSD more carefully. Your file starts with the element <MessageEntit y> whereas you XSD states that the first element should be <Notification >.

The following example will show you how to get started:

<Notification >
<Email>
<Message>
...
...
</Message>
</Email>
</Notification>

Follow the XSD, looks a bit strange in this case did you write it?, and everything should be ok.

Hope this helps.
Aug 29 '07 #2
johnsonkt
3 New Member
hi ,
thanks for the reply.

i tried on what u said.now my xsd looks

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDe fault="unqualif ied" elementFormDefa ult="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MessageEn tity">
<xs:complexType >
<xs:sequence>
<xs:element name="Email">
<xs:complexType >
<xs:sequence>
<xs:element name="Message">
<xs:complexType >
<xs:sequence>
<xs:element name="From" />
<xs:element name="Recipient s">
<xs:complexType >
<xs:sequence>
<xs:element name="Recipient ">
<xs:complexType >
<xs:attribute name="recipient id" type="xs:string " use="required" />
<xs:attribute name="retryatte mpts" type="xs:unsign edByte" use="required" />
<xs:attribute name="templatei d" type="xs:unsign edByte" use="required" />
<xs:attribute name="subject" type="xs:string " use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateI d" type="xs:unsign edByte" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryatte mpts" type="xs:unsign edByte" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="Sms">
<xs:complexType >
<xs:sequence>
<xs:element name="Message">
<xs:complexType >
<xs:sequence>
<xs:element name="From" />
<xs:element name="Recipient s">
<xs:complexType >
<xs:sequence>
<xs:element name="Recipient ">
<xs:complexType >
<xs:attribute name="recipient id" type="xs:string " use="required" />
<xs:attribute name="retryatte mpts" type="xs:unsign edByte" use="required" />
<xs:attribute name="templatei d" type="xs:unsign edByte" use="required" />
<xs:attribute name="subject" type="xs:string " use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateI d" type="xs:unsign edByte" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryatte mpts" type="xs:unsign edByte" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

now the xml string and xsd matches.but still the same error. the xsd was created automatically by the visual studio 2005 on submitting the xml document.
Aug 29 '07 #3
MarkoKlacar
296 Recognized Expert Contributor
What does your XML-file look like now?

I don't know how much you know about XML and XSD but the idea is that the XSD is a description of how the XML-file must look, i.e how the elements have to be organized in what order etc.

Is the XML-file also auto-generated or are you the one writing it?
Auto generation is good, but you should only use it once you master the things you are working with.
Aug 30 '07 #4
jkmyoung
2,057 Recognized Expert Top Contributor
If you're generating this xml from a program, what class are you using to output the xml? You may be encountering an encoding problem.
Aug 30 '07 #5

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

Similar topics

3
5937
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
1
1825
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
9
6653
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 of which class to de-serialize to. In the attached code I substituted @@@@@@@ in the code below with...
0
1410
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
2
10054
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 the following error, and stating that there is something with the Web Service or the SOAP Client...
1
2767
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 with ASP.Net 2.0, it doesn't work. It returns the following error message: "Data at the root level...
1
11579
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 xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt; ...
2
3230
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 2008 01:16:09 -0000
3
3300
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 source file appropriately. Parser Error Message: Data at the root level is invalid. Line 1,...
0
9639
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8964
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4040
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
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.