473,788 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML validation error. Help required

XML validation error. Help required
If anyone can help me, thankyou, thankyou...

When I run this code code I get this error:
The data at the root level is invalid. Line 1, position 39.

I can't work out what the error is. Can you???

original code:
Dim oRead As XmlTextReader
Dim oValid As XmlValidatingRe ader

Try
oRead = New XmlTextReader(" C:\custdoc.xml" )
oValid = New XmlValidatingRe ader(oRead)

AddHandler oValid.Validati onEventHandler, New Schema.Validati onEventHandler( AddressOf ValidationError )
oValid.Schemas. Add("newschema" , "C:\custschema. xsd")
oValid.Validati onType = ValidationType. Auto

Do While oValid.Read
'let validation do its thing
Loop...
xml doc file:
<?xml version="1.0" encoding="UTF-8"?>
<myroot xmlns:xx="gener ic">
<xx:Customer>
<xx:ID>"000001" </xx:ID>
<xx:Name>"CustO ne"</xx:Name>
</xx:Customer>
<xx:Customer>
<xx:ID>000002 </xx:ID>
<xx:Name>CustTw o</xx:Name>
</xx:Customer>
</myroot>

xml schema file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="generic" elementFormDefa ult="qualified" targetNamespace ="generic">
<xs:element name="myroot">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Customer" >
<xs:complexType >
<xs:sequence>
<xs:element name="ID" type="xs:string " minOccurs="0" />
<xs:element name="Name" type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks, Stu
--------------------------------
From: stuart dent

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>pVvJYVwbZUe vEQlnr5NghQ==</Id>
Nov 12 '05 #1
1 3365
"stuart dent via .NET 247" <an*******@dotn et247.com> wrote in message news:OU******** ******@TK2MSFTN GP15.phx.gbl...
When I run this code code I get this error:
The data at the root level is invalid. Line 1, position 39. : : <?xml version="1.0" encoding="UTF-8"?>


Anytime you receive an XmlException where the position is at the very end of the XML declaration,
the XML declaration has no syntax errors, and that XML declaration has an "encoding" pseudo-
attribute, then it means the file is _not_ whatever that encoding pseudo-attribute says.

Therefore, the file is not UTF-8 encoded. Try loading it into Notepad and then doing File | Save As..
and choosing UTF-8 from the Encoding drop-down box. Alternately, change the encoding pseudo-
attribute to indicate what the encoding of the file truly is.

The file that's the culprit depends on whether the XmlException was thrown from the XmlTextReader
(it's then the instance document that has the invalid encoding) or the Add( ) to the XmlSchemaCollec tion
(it's then the schema document that has the invalid encoding).
Derek Harmon
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1551
by: Matt Mercer | last post by:
Hi, My first post here. I am a self-taught, very "green" web developer. It is not the main focus of my job but required from time to time. I am developing a web application that logs security incidents for my company. Here is a little background on how it works. I am using ASP ..net and VB. The user first submits a new incident which has several required and not required fields related to the incident. The new incident is written to a...
5
3073
by: Helen | last post by:
Hi I'm using ASP.NET's standard validators to display error messages when people don't fill in required fields on my form. The error messages currently show as soon as the form is loaded, but what I'd really like is for the error messages to only be displayed after the validation fails. Is this a feature of the standard ASP.NET validation or will I have to write custom validators if I want to do that?
2
3737
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post all the messages to a message box (ShowMessageBox=true). The required field validation error messages show up in the summary just fine but I can't get the custom validation message to show up if invalid. So far I have the summary control...
7
2050
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. In IE, the validation works, but no form ever gets submited. It doesn't even process the click event of the button. In mozilla, it works 100% (this is weird because it's usually the oposite). Any thoughts?
2
2435
by: ticars | last post by:
I have a telephone number user control in which I need to validate the data entered (Required field validation and regular expression validation). The phone number is represented as 3 text boxes so I have 3 required field validation and regular expression validation controls. I set the display property to none and have a validation summary control in my hosting page. I have a method in the user control that then assigns the error message...
7
6999
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form is correct I need to submit to another page that uses the form data. I first tried making the form submit action= field point to the same file. When the form was correct, I tried loading the next page by using <META http-equiv refresh>. But...
10
5725
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the form the control is on? Basically I have a number of controls in a form that are required, and to check it I am setting the Validation Rule to "<>"IsNull" so that when the user tries to tab through/click out of a required area without entering...
7
3621
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
0
2682
by: tanish2k | last post by:
hi. I am using c#, visual studio 2003. I need to validate a xml file against schema which itself has 2 more schema imported under it. i have following 2 xsd files : xsd1 ---> ------------------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema
3
6226
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it has to tell then them its wrong information but currently it takes then to a next page and then tells them its incorrect information. This is tedious as every time they enter wrong they will be redirected to a different page and then they have to...
0
10370
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
9969
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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
7519
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...
0
6750
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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
3
2896
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.