467,081 Members | 989 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,081 developers. It's quick & easy.

How do I use schemas on my desktop?

Hello. I'm new to using XML/HTML. I am trying to learn to validate
xml sample docs against schemas. I have an XML and Schema file (.xsd)
saved to my desktop. Below is my sample code, which is borrowed from
the .NET help files. It blows up when I try to refererence a schema
that is on my desktop.

If you can, please correct my misunderstanding about referencing
schemas, as evidenced in the below example. Am I attempting the
impossible, or just attempting the possible wrongly?

Thanks for any help,

Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Schema

Public Class validationhandler

Public Shared Sub callvalreader()
Dim stream As New FileStream("C:\Documents and
Settings\mgoold\Desktop\Input\xmlexample.xml", FileMode.Open)
Dim vr As New XmlValidatingReader(stream, XmlNodeType.Element,

vr.Schemas.Add("\\Documents and
Settings\mgoold\Desktop\Input\Schematrial.xsd", "//C:/Documents and
vr.ValidationType = ValidationType.Schema
AddHandler vr.ValidationEventHandler, AddressOf

While vr.Read()
End While
Console.WriteLine("Validation finished")

End Sub

Public Shared Sub ValidationHandler(ByVal sender As Object, ByVal
args As ValidationEventArgs)
Console.WriteLine("***Validation error")
Console.WriteLine("Severity:{0}", args.Severity)
Console.WriteLine("Message:{0}", args.Message)
End Sub

End Class

Aug 4 '06 #1
  • viewed: 820

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

30 posts views Thread by btober@seaworthysys.com | last post: by
7 posts views Thread by Roderick A. Anderson | last post: by
4 posts views Thread by anonymous@coolgroups.com | last post: by
2 posts views Thread by John Jenkins | last post: by
6 posts views Thread by Dennis Gearon | last post: by
reply views Thread by Net Virtual Mailing Lists | last post: by
3 posts views Thread by Sami Marzouki | last post: by
reply views Thread by mgoold2002@hotmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.