473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

xml validation

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" ?>
<MessageEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Email retryattempts="1">
<Message>
<From>NotificationEmail</From>
<Recipients>
<Recipient recipientid="email@gmail.com" retryattempts="1" templateid="0" subject="email" />
</Recipients>
<Subject>email</Subject>
<Body>hi this is email body</Body>
<TemplateId>0</TemplateId>
</Message>
</Email>
<Sms retryattempts="0">
<Message>
<From>Notificationsms</From>
<Recipients>
<Recipient recipientid="9986267364" 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 attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Notification">
<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="Recipients">
<xs:complexType>
<xs:sequence>
<xs:element name="Recipient">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="recipientid" type="xs:string" use="required" />
<xs:attribute name="retryattempts" type="xs:string" use="required" />
<xs:attribute name="templateid" type="xs:string" use="required" />
<xs:attribute name="subject" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateId" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryattempts" 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="Recipients">
<xs:complexType>
<xs:sequence>
<xs:element name="Recipient">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="recipientid" type="xs:string" use="required" />
<xs:attribute name="retryattempts" type="xs:string" use="required" />
<xs:attribute name="templateid" type="xs:string" use="required" />
<xs:attribute name="subject" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" />
<xs:element name="Body" />
<xs:element name="TemplateId" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="retryattempts" 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
1 980
phvfl
173 Expert 100+
The problem seems to be that the root node name in the XML is MessageEntity whereas the XSD stipulates that the node should be called Notification.

There is no problem in IE because I assume that it does not try to apply the XSD.
Aug 29 '07 #2

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
2
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
6
by: Stephen | last post by:
Hi, the validation controls dont work on Netscape or Mozilla and only on Internet Explorer why? How do i correct this problem? Thanks
7
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. ...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
2
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
6
by: Jon Paal | last post by:
validation doesn't fire what's missing ????? /////// ---- code -----/////////////////////////// Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.