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

dotnet xml : Using just the XmlDocument to validate xml against an xsd schema


John H
12/5/2005 7:40:25 AM
Hi,
How can i just use the XmlDocument object to validate an xml instanace
against a schema referenced inside the xml instance?
The Load method seems to not validate it against the schema.

Thanks
John
Martin Honnen
12/5/2005 6:45:04 PM


[quoted text, click to view]

There is an overload for the Load method that takes an XmlReader:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassLoadTopic4.asp>
There you can pass in an XmlValidatingReader set up properly which
performs the validation.


With .NET 2.0 there is also a new method called Validate
<http://msdn2.microsoft.com/en-us/library/ms162370(en-US,VS.80).aspx>
which allows you to validate the document after it has been loaded and
manipulated.

See also
<http://66.129.71.130/QuickStartv20/howto/doc/Xml/ValidationReadingXML.aspx>
<http://66.129.71.130/QuickStartv20/howto/doc/Xml/XmlDocumentValidation.aspx>
for .NET 2.0 specific changes respectively solutions.



--

Martin Honnen --- MVP XML
John H
12/9/2005 6:59:38 AM
Thanks very much.
JOhn
AddThis Social Bookmark Button