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

XML Document validation against XSD file


Hi,

I got this code to validate my XML against a XSD schema, and it works fine.

static void ValidatingProblemHandler(object sender, ValidationEventArgs e)
{
if ((e.Severity == XmlSeverityType.Warning) || (e.Severity ==
XmlSeverityType.Error))
{
MessageBox.Show(e.Message + " " + String.Format("\n\nLine: {0},
Position: {1} \"{2}\"",
e.Exception.LineNumber, e.Exception.LinePosition,
e.Exception.Message));
}
}
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"c:\Request.xml");
xDoc.Schemas.Add("",@"c:\ApplicationCompletionRequ est.xsd");
xDoc.Schemas.Compile();
ValidationEventHandler validator = ValidatingProblemHandler;
xDoc.Validate(validator);
I would like to know which node of the document the validation failed, not
only the node name and the value, which could be duplicated in more than one
part in my XML document due to the structure of my XML document
Any suggestion?
Thanks,
Filippo

Jun 18 '07 #1
0 977

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

Similar topics

2
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using...
2
by: Sudip Chakraborty | last post by:
Is there a way to see constraint validation errors while loading xml into a DataSet ? I'm interested in the line number in the xml file which is causing the error. I've enclosed the relevant stack...
1
by: Izvra | last post by:
How can i specify default XML namespace when it does not declared in the xml document I need it for validation against xml schema @@@I have a procedure Sub ValidateXMLDocument(ByRef XMLDocument...
3
by: Emily John | last post by:
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...
5
by: Doru Roman | last post by:
Hi, I am a beginner and I try to understand how can I use C# and Netframework to validate an XML document. Is XSD a solution? How? Thanks, Doru
1
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this...
2
by: Bardo | last post by:
Hi all, Does anyone know if it is possible, and if so how, to perform validation of a simple non XML string against certain XSD restrictions, without having the entire XML document to validate...
2
by: =?Utf-8?B?RmlsaXBwbyBCZXR0aW5hZ2xpbw==?= | last post by:
Hi, I got this code to validate my XML against a XSD schema, and it works fine. static void ValidatingProblemHandler(object sender, ValidationEventArgs e) { if ((e.Severity ==...
2
by: Bruno Schneider | last post by:
I've seen this page, that seems invalid to me. Doctype is incomplete and it does not have a <bodytag. However, W3C validator validates it as HTML 4.01 strict, even when I force the DOCTYPE. I think...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.