|
-
Sep 8th, 2004, 11:47 PM
#1
Thread Starter
New Member
XML / vb.net help required
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>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|