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 XmlValidatingReader

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

AddHandler oValid.ValidationEventHandler, New Schema.ValidationEventHandler(AddressOf ValidationError)
oValid.Schemas.Add("newschema", "C:\custschema.xsd")
oValid.ValidationType = 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="generic"> 
<xx:Customer>
<xx:ID>"000001"</xx:ID>
<xx:Name>"CustOne"</xx:Name>
</xx:Customer>
<xx:Customer>
<xx:ID>000002</xx:ID>
<xx:Name>CustTwo</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" elementFormDefault="qualified" targetNamespace="generic">
<xs:element name="myroot">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<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>pVvJYVwbZUevEQlnr5NghQ==</Id>
0
9/15/2004 6:44:02 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
574 Views

Similar Articles

[PageSpeed] 41

"stuart dent via .NET 247" <anonymous@dotnet247.com> wrote in message news:OUCL5P1mEHA.2076@TK2MSFTNGP15.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 XmlSchemaCollection
(it's then the schema document that has the invalid encoding).


Derek Harmon


0
loresayer (274)
9/16/2004 12:55:10 AM
Reply:

Similar Artilces:

XML Header
Hi, I have some XML doc loaded in a C# Web Service. XmlDocument doc = new XmlDocument(); doc.LoadXml(myDoc); Code Missing to manipulate header (I would like to replace or manupulate all these XXXXX): <mso-XXXXXX productversion="XXXXXX"> <mso-application progid="XXXXX"?> doc.Save(myNewDoc); Any idea on how to access and manipulate data within the doc header? Thanks vbdev vb6dev2003 wrote: > I have some XML doc loaded in a C# Web Service. > XmlDocument doc = new XmlDocument(); > doc.LoadXml(myDoc); > > Code Missing to manipulate header ...

aliases generate error -10660
I just installed Office 2004 on a new iMac running OS 10.3.6 If the office application is not running and I double-click on an office document, I get the error message The operation could not be completed. An unexpected error occurered (error code -10660). If I have the application running and double click on a document it opens fine. Double clicking documents from other applications properly opens the application. I've uninstalled & reintstalled and problem still exists. Suggestions? Thanks, David In article <a5608d5.0412021043.5032a4d4@posting.google.com>, david@teton1....

Read XHTML into XML
Hi all, I need to read/parse XHTML aspx pages and look for certain tokens and content. How can I use a XmlTextReader for this? If not, any other ideas? Thanks in advance, JA Reyes. Jose Antonio Reyes wrote: > I need to read/parse XHTML aspx pages and look for certain tokens and > content. How can I use a XmlTextReader for this? If not, any other ideas? If the pages are well-formed XHTML then it is possible to use XmlReader (in .NET 2.0/3.0) or XmlTextReader (in .NET 1.x) to parse the XHTML documents. You can also use the other XML APIs .NET provides so using XPathNavigator and/o...

Security Service Error
This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C3F55C.A5DEBC20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ok, I have a problem... my CRM Security Service fails to start and this = is the error I get: Source: MSCRMSecurityService Event ID: 5920 Error: An error occurred while attempting to update the SCP (Active = Directory update). -2147016656 (0x80072030) Description: There is no = such object on the server. I used to work then i rebooted and now this... Any Ideas, everything = else seems to be running ...

Sign-in error
Money 2002 has been working fine until recently. When signing on with my .Net Passport keep getting 2 error messages... "Money is unable to verify your online sign-in. Money will now try to log you in using Work Offline sign-in. Some online features, such as background banking, will be unavailable possibly because of network problems. To use online features, please close Money and try to sign again later." After clicking okay on that message, I get another error message... "The sign-in attempt for < > was unsuccessful. Please try your sign in name and passwor...

Corrupted .pst file !!!?!?! Help
Hi, My outlook.pst is corrupted. Tha'ts why I cannot start me outlook 2003 (see my other post here) I used the inbox repair tool (SCANPST.EXE) but it doesn't work, I got the following message: "An unexpected error prevented access ti this file. Use scandisk to check the disk for errors and then try using the inbox repair tool again" Outlook is closed and I already scanned my hard disk using scandisk, and there are no error. The error really seems to come for the corrupted pst file. Related to the file corruption, When I tried to copy the outlook.pst file to an...

How to invoke the xml editor?
I installed vs2005 on a new xp pro machine, and installed everything except C++. When I click on a file with a ".xml" extension it is opened with IE. When I click file/Edit with XML Editor, it opens it with Notepad. If I click File/Open With and select XML Editor, it opens it with IE. So, where is the xml editor? Can it be invoked from withing VS? Where? Bill * billsahiker@yahoo.com wrote in microsoft.public.dotnet.xml: >I installed vs2005 on a new xp pro machine, and installed everything >except C++. When I click on a file with a ".xml" extension it is >opened ...

Outlook error message #45
Hello, I have had Outlook 2007 installed on my laptop for months with no issues. 2 weeks ago the program would occasionally give me an error message "your email server rejected your login. Verify your user name and password in account properties...". Now 2 days ago this message pops up all the time and I no longer can send/receive emails. I have tried to repair Outlook, un-installing, and re-installing, nothing seems to work! Which Anti Virus are you using to scan incoming and outgoing email -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistan...

Birthday entry error
I have Win 7 Home Premium x64 and WLMail. When editing my contact, I tried to use a pop down calendar in the Birthday entry area. I opened calendar and clicked Feb 3, 2010, however the date on the line appeared as March 2... July 11 transferred into Nov 7, etc. Entering manually 03/02/xxxx produces correct entry 03 Feb xx, manual entry of 11/07/xxxx results in the correct 11 Jul xx, etc. Entering birthdate on Contacts.com do not change rntry on my desktop. May someone please tell me what's the correct way to enter the birthday info? Also, what is the easy way to get to a drop ...

Validation List not showing external source.
I have a external reference on a Data Validation but the list will not show up unless I have the external reference spreadsheet open. I can manually type in the exact selection and it works fine. Unless I have the refernced spread sheet open, I can not see the list options. Is there a fix for this or is this a limitation on Excel? Any work arounds? David, Did you find the answer? --- Message posted from http://www.ExcelForum.com/ ...

Distribution List Error...
I have a couple of users that have created a distribution list in their contacts and when they go to send to it they get the following error... Microsoft Office Word An internal support function returned an error Now the funny thing is if I change their settings to not use word as their email editor it will send but only until they log off. When they log back on I have to set it to use Word as their email editor or change it to Rich Text. Has anybody else had this happen? If so, what is the resolution? ...

show XML schema and values
I have an XML document that looks like the following: <record> <Field1>value1</Field1> <Field2>value2</Field2> <Field3>value3</Field3> </record> What I'm aiming to do is to show the data in a report as in the following example: record: Field1 value1 Field2 value2 Field3 value3 The "Field1-3"-elements can have any name, so I'm trying to get a table that has in one result column the element name, and in the second colum...

activesheet error
Hi I've done something wrong here and I can't work out what it is... Error msg: "Compile Error: With object must be user-defined type, object, or Variant" Sub copylplan() Dim mySheet As String mySheet = ActiveSheet With mySheet .Copy After:=Sheets(Sheets.Count) End With With mySheet .Name = "Extract Plan" End With End Sub -- Thank for your help BeSmart Hi, Set the variable as a Worksheet then use Set in the line to assign the ActiveSheet to the variable. You should realize that the variable rem...

PLEASE HELP WITH ATTACHMENTS
I cannot receive messages with attachments. It goes back to the sender saying "The content length of the message is too long for the recipient to take delivery" How do I change this? In Tools/Options/Mail Delivery check yr settings for 'Dont download msgs larger than xx kb' David "Fanny" <fcruz@FirstNorthernCU.org> wrote in message news:097401c35522$fd713650$a501280a@phx.gbl... > I cannot receive messages with attachments. It goes back > to the sender saying "The content length of the message is > too long for the recipient to take delive...

run-time error when I re-print an Invoice
Hello I am new to RMS and I am trying to figure out the reason of the run-time error every time I try to re-print an invoice or press the journal button. the error will result in terminating my existing application (POS) and the error also says that t"disconnecting from client...) and give me an error numbers. Any help? HI Alex, can you please specific the exact error no so we can help you in better way. actually wanted to know what create error, also do you know how to check the event log in windows OS check the application event log and find what error or what is the reason your...

Error after Outlook reinstall
This would pop up. Error - Could not obtain Microsoft Outlook version Also, I can't install the microsoft updates to outlook because it says because it doesn't know it's version. -- Kate So what version of Outlook did you re-install -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "SFKate" <SFKate@discussions.microsoft.com> wrote in message news:1F6F470A-D977-42CE-A342-909DAA07FE2A@microsoft.com... > This would pop up. Error - Could not obtain Microsoft Out...

outlook 2000 mailbox.pst error. inbox repair tool
hi all I am getting a error message from outlook 2000 that says errors have been detected in the file c:\windows\application data\microsoft\outlook\mailbox.pst It says to use the inbox repair tool. I have searced microsoft online help and found the site "ol2000 how to find and run the inbox repair tool" I am using ME. I have been looking for "Scanpst.exe" file. Microsoft help says to follow c:\program files\common\system\Mapi\1033\nt I cannnot find a file by this name. I can find a file c:\program files\common\system\Mapi\1033\95 when I run "Scanpst.exe&qu...

Offline synch using XML web-services
This is a bit long-winded. Can somebody read thru these 2 use cases, and tell me if it is feasible ? :- Use Case : Replication before Offline Synch Scenario 1 : Oracle Server , MSDE client 1. User clicks on 'Go Offline'. System creates a MSDE SQL database in laptop (client), gets the schemas of the tables in Oracle, creates corresponding tables in client's MSDE SQL (mapping Oracle datatypes to SQL datatypes). 2. Offline replication program reads in the tables of the server into a typed datasets, converts the typed datasets into XML, and stores the XML in the client. (XML serial...

XML Serialization ... how to truncate <?xml...
While xml serializing object how can I truncate <?xml ...?> this line alone? I need to send the serialized xml data to a web method ... since SOAP already have <?xml tag there was some confusion Any help would be greatly appreciated Thank you Regards Raj Raj wrote: > While xml serializing object how can I truncate <?xml ...?> this line alone? Serialize to an XmlWriter created with XmlWriterSettings where you set OmitXmlDeclaration to true. -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ ...

oe error 0x800c012f
I cannot receive and send emails in Outlook Express! There are no tasks in the progress window. But there is an error: 0x800c012f. What does it mean? Hi - This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program, despite its similar name.. You will probably get a faster and more expert answer if you post this to an Outlook Express news group. Try posting in one of these newsgroups: microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x microsoft.public.windows.inetexplorer.ie55.outlook...

compile error #3
Every time I start excel (2002) I receive an error message: "compile error in hidden module: TBRun97". If I click "HELP" on the error message, I get an empty help window. If I click "OK", the error message goes away and I am able to work in excel. The same error occurs when I exit the program. Help please. Here's an MSKB article that describes Don's response: XL: Compile Error in Hidden Module Tbrun97.xls http://support.microsoft.com/default.aspx?scid=kb;en-us;272066 Leo wrote: > > Every time I start excel (2002) I receive an error >...

error adding new Schema Field 04-21-04
Hi, When I attempt to add a new schema field to the "Lead" object in the Deployment Manager, I get the following error: "An error occured during the addtion of the new field. The addition failed." In the event log, I there are two relevant entries: "dmLog: Failed to add new Picklist attribute (CFPsolution) to Lead entity" and "dmLog: sp_repladdcolumn failed. - Timeout expired" I've previously successfully added a pickup list called "Sector" with 9 values. Therefore I don't think I've exceeded the 8000 char row limit. Apart from...

String to xml document
Hi there, I was hoping someone can help me with a little problem I can't seem to find any answers to. I've got a form wich will be posted. On receiving the post I would like to parse a formvar to a xml document. The contents of this formvar (string) will be a valid xhtml document. Can someone give me a startertip (or more :-)) on how to achieve this? tnx in advance, James van der Veen Sjeems wrote: > I was hoping someone can help me with a little problem I can't seem to find > any answers to. > > I've got a form wich will be posted. On receiving the p...

Beginner of XML
I am a beginner of XML. I want to group some files together with a xml file. (it includes a text file, and an image file and a video file) Can someone show me some guidelines? Please help. ...

Valid xml to read from an xml file?
I'm using vb.net, i get an error at the reader line saying the remote server can't be found. Is the below even valid? dim reader as XmlTextReader reader = new XmlTextReader ("http://www.mysite.com/my.xml") do while (reader.Read()) 'do some action here response.write(reader) loop thanx chumley XmlTextReader uses System.Net.WebRequest under the covers -- see if you can figure out how to create a connection that way. Usually there's some proxy server information missing that you can enable if you use WebRequest directly, and then pass the result of GetResponse()...