473,382 Members | 1,615 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,382 software developers and data experts.

validate against xsd

CK
I am doing a

Doc.Loadxml(myxml)
and I have an xsd schema that I want to validate the myxml against. How can
I do this. code would help.
Thanks in advance.
Nov 16 '05 #1
3 1449
you might wan to check this out

http://www.csharpfriends.com/Article...?articleID=102

HTH

Ollie Riches
System.Xml.Schema

"CK" <jo*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I am doing a

Doc.Loadxml(myxml)
and I have an xsd schema that I want to validate the myxml against. How
can I do this. code would help.
Thanks in advance.

Nov 16 '05 #2
Hi
There is no built in support for that in the XmlDocument class. This is
because you can built your document object element by element ( so at some
stage it would not be valid against your schema ) . What you can do however
it to copy your document to a dataset object where all these operations can
be done. You can also enforce your schema while filling your dataset form
the document object.
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
> Doc.Loadxml(myxml)
and I have an xsd schema that I want to validate the myxml against. How
can I do this. code would help.


You can use the XmlValidatingReader class to validate against the schema. To
validate the xml fragment in your "myxml" string do this:

NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
XmlSchemaCollection xsc = new XmlSchemaCollection();
xsc.Add("urn:myschema", "myschema.xsd");
XmlParserContext context = new XmlParserContext(null, nsmgr, null,
XmlSpace.None);
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
reader.Schemas.Add(xsc);

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 16 '05 #4

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

Similar topics

1
by: QuantDev | last post by:
Hi NG, I would need to validate an XML fragment against a type defined within an XSD (which defines many other things). What is the correct way of achieving this? QD2004
1
by: Ron Rohrssen | last post by:
I've been working on learning XML schemas and trying to make use of the MS classes for validating data against a schema. So, I've been trying to work through some simple schemas and instances....
1
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
6
by: LesleyW | last post by:
Hi Apologies if this is a really dumb question, but being new to XML and Schemas, I wonder if giving the namespace for eg xsd or xsi as a website address means that the user has to be online...
7
by: Ali-R | last post by:
Hi all, I am getting a CSV file like this from our client: "C1","2","12344","Mr","John","Chan","05/07/1976"......... I need to validate **each filed value** against a set of rules ,for...
4
by: Mr. x | last post by:
Hello, I know about the validator on : http://validator.w3.org , which can validate html pages. I just new to this validator. How can I validate (if it can be - by this validator) aspx pages,...
2
by: John H | last post by:
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. ...
3
by: Rushi | last post by:
Hi All, Is it possible to Validate XML against XSD using two different XML files. scenario: There are two different XML file, one file contain element and count information and other one...
1
by: engwar | last post by:
The title says it all. How do I use XMLDocument.Validate() against a DTD. In all my Googling about this I only find examples of how to validate an XMLReader or XmlValidatingReader against a DTD....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.