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>