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>