Groups | Blog | Home
all groups > dotnet xml > december 2005 >

dotnet xml : How to validate an Xml doc with XSD


Gilles Lambert
12/20/2005 6:11:06 AM
Hi, i'm trying to validate a doc.xml against a schema XSD this way, but
it doesn't validate anithing :

Dim xrs As New XmlReaderSettings
xrs.Schemas.Add("urn:mediatheque-lrvb8", "schema.xsd")
xrs.ValidationType = ValidationType.Schema

AddHandler xrs.ValidationEventHandler, AddressOf Validation

Dim xr As XmlReader = XmlReader.Create("doc.xml", xrs)

Using xr
Do While xr.Read
Loop
End Using

The EventHandler is never called : i just put any tag, just keeping the
xml doc well formed and nothing appens ?

Thanks and best regards.
Gilles




Martin Honnen
12/20/2005 3:31:19 PM


[quoted text, click to view]

Here is a complete example from the .NET 2.0 quick start samples
<http://66.129.71.130/QuickStartv20/util/srcview.aspx?path=~/howto/samples/Xml/ValidationReadingXml/ValidationReadingXML.src>
perhaps that helps.

If not then consider posting enough of your code that we can reproduce
what you are doing, we need to see the XML input and the schema.


--

Martin Honnen --- MVP XML
Gilles Lambert
12/21/2005 1:10:59 AM
Hi Martin,

My pb came from the xmlns attribute i ommited in the xml file : it's
mandatory (and not very well explained in the doc !).

Thanks for your answer, and for the Url i visited on www.asp.net :
simply great !!!

Best regards
Gilles



SimonJackson
1/18/2006 2:22:22 AM
Hi

The following link is a Free tool for validating XML and XSD documents.

http://www.liquid-technologies.com/Tools/FreeTools.aspx

Regards Simon
AddThis Social Bookmark Button