473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to validate an Xml doc with XSD

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


*** Sent via Developersdex http://www.developersdex.com ***
Dec 20 '05 #1
3 1429


Gilles Lambert wrote:
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 ?


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
http://JavaScript.FAQTs.com/
Dec 20 '05 #2
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

*** Sent via Developersdex http://www.developersdex.com ***
Dec 21 '05 #3
Hi

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

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

Regards Simon

Jan 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below)...
5
by: Jim Heavey | last post by:
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be...
11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
0
by: Marc Scheuner | last post by:
Folks, I'm faced with a dilemma here - I have an XML document and for part of it, I have an XSD schema to validate it - but not for the rest of it. Can I still validate at least part of the...
4
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I...
24
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.