471,334 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Prescise error messages from XmlValidatingReader - possible or not?


I have the following problem.

I want to use the validating parser XmlValidatingReader and so I write ...

FileStream stream = new FileStream(ofd.FileName, FileMode.Open);
XmlValidatingReader rdr = new XmlValidatingReader(
stream, XmlNodeType.Element, null);
rdr.ValidationEventHandler += eventHandler;
rdr.ValidationType = ValidationType.Auto;
doc = new XmlDocument();

This program works without a little exception.

I have a xsd-file - well formed and valid - and a xml-file based on that
xsd, well formed and valid too, both written and testet with atova xml spy.

But instead of this, the XmlValidatingReader throws errors. In the
eventhandler i get a message, that (translated from German) "Keyref
cannot find the 'key'- or 'unique'-Element, which is pointed out by

Independently of the problem - it is an xml-Problem and off Topic here -
I'm interested in writing a proper error message which contains the line
number of the xml file which produces the error. The xml-file has more
than 1000 lines and it is not a good idea to say "Somewhere in that file
there is something wrong"

Can you give me a hint to improve the quality of my error message.

Thanks and best regards
Wolfgang Uhr
Feb 9 '06 #1
1 1232
Hi Wolfgang,

This might be the difference between .NET xml parse and the Xml spy parser.
Unfortunately, we can do nothing to improve the quality of the error
message, because it was generated from inside of the Xml parser. If you
need better error message, you might need to implement your own parser.

Kevin Yu
"This posting is provided "AS IS" with no warranties, and confers no

Feb 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bill Cohagan | last post: by
reply views Thread by Sangeetha Nagaraj | last post: by
5 posts views Thread by Patrick | last post: by
reply views Thread by John Harcourt | last post: by
reply views Thread by rosydwin | last post: by

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.