By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

Validation of xml document at load time.

P: n/a


I am using xml serialization to generate my xml document. I am getting
the data as stream of memory and then converting it to xml document
object without saving it to the file system.

How do I validate this memory stream of data at load time with xml
schema ?

I may have to validate with multiple schemas at a later time.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Emily

You need a layered approach here. Use the XmlTextReader on your stream, then
construct a ValidatingXmlReader using the TextReader, and then pass the
validating reader through to the Load method of your XmlDocument.

Code like this:

Dim t As New Xml.XmlTextReader(stream)
Dim v As New Xml.XmlValidatingReader(t)
Dim doc As New Xml.XmlDocument
doc.Load(v)

HTH

Nigel

"Emily John" wrote:


I am using xml serialization to generate my xml document. I am getting
the data as stream of memory and then converting it to xml document
object without saving it to the file system.

How do I validate this memory stream of data at load time with xml
schema ?

I may have to validate with multiple schemas at a later time.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

P: n/a


Exactly ! I did the same thing. But where does I make a call to validate
it against schema ?

Does XMLValidatingReader does the validation automatically ? Which
schema it validates against ?? I need to clearly understannd the
doc.Load(v) call adn how is validates.

Can you please help ??

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

P: n/a
Hi Emily

Take a look at the ValidationType and Schemas properties.

With ValidationType set to Auto, then if you can use the xsi:schemaLocation
/ xsi:noNamespaceSchemaLocation to hook into validation.

You can also add a Schema or collection of Schemas to validate against with
the Schemas property.

HTH

Nigel Armstrong

"Emily John" wrote:


Exactly ! I did the same thing. But where does I make a call to validate
it against schema ?

Does XMLValidatingReader does the validation automatically ? Which
schema it validates against ?? I need to clearly understannd the
doc.Load(v) call adn how is validates.

Can you please help ??

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.