IT Community - Software Programming, Web Development and Technical Support

.Net support validating XML?

This is a discussion on .Net support validating XML? within the XML and SOAP forums, part of the Web Development category; Hi guys, Can any one explain .Net support validating XML documents against DTDS? Thanks devarajan.V...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > XML and SOAP

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 07-25-2007, 07:04 AM
devarajan.v devarajan.v is offline
D-Web Master
 
Join Date: May 2007
Posts: 382
devarajan.v is on a distinguished road
Question .Net support validating XML?

Hi guys,

Can any one explain .Net support validating XML documents against DTDS?


Thanks
devarajan.V
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 07-27-2007, 08:22 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Default Re: .Net support validating XML?

Hi devarajan.v

Yes, .Net Supports validating XML document against DTDS.

In .Net framework System.Xml Namespace contains all the neccessary classes and methods to do this.


Some of the Classes for this perpose are...

XmlTextReader in System.Xml Namespace

XmlValidatingReader in System.Xml Namespace

XmlSchema in System.Xml.Schema Namespace

XmlSchemaCollection in System.Xml.Schema Namespace


Hope usefull to u..

Oxygen
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-13-2007, 10:53 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 881
kingmaker is on a distinguished road
Send a message via MSN to kingmaker
Default Re: .Net support validating XML?

private void ValidatingProcess(string XSDPath, string XMLPath)
{
try
{

Reader = new XmlTextReader(XMLPath);


StreamReader SR = new StreamReader(XSDPath);


XmlSchema Schema = new XmlSchema();



Schema = XmlSchema.Read(SR,
new ValidationEventHandler(ValidatingReader_Validation EventHandler));


XmlValidatingReader ValidatingReader = new XmlValidatingReader(Reader);

ValidatingReader.ValidationType = ValidationType.Schema;

ValidatingReader.Schemas.Add(Schema);



ValidatingReader.ValidationEventHandler +=
new ValidationEventHandler(ValidatingReader_Validation EventHandler);


while (ValidatingReader.Read())
{/*Empty loop*/}

}

catch (UnauthorizedAccessException AccessEx)
{
throw AccessEx;
}
catch (Exception Ex)
{
throw Ex;
}
}

private void ValidatingReader_ValidationEventHandler(object sender,
ValidationEventArgs args)
{
// 10- Implement your logic for each validation iteration
string strTemp;
strTemp = "Line: " + this.Reader.LineNumber + " - Position: " +
this.Reader.LinePosition + " - " + args.Message;

this.Results.Add(strTemp);
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
validating a form AND preventing multiple clicks sureshbb HTML, CSS and Javascript Coding Techniques 1 12-04-2007 12:14 AM
Validating Numbers ragavraj PHP Programming 1 11-07-2007 06:12 AM
If I am validating a form AND preventing multiple clicks, is the following code corre theone HTML, CSS and Javascript Coding Techniques 1 07-30-2007 05:13 AM
Which JavaScript file is referenced for validating the validators at the client side? sundarraja ASP and ASP.NET Programming 1 07-27-2007 04:26 AM
Which Javascript file is referenced for validating the validators at the client side? mobilegeek HTML, CSS and Javascript Coding Techniques 1 07-25-2007 10:15 PM


All times are GMT -7. The time now is 06:54 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0