Net xml validating reader
None); Xml Validating Reader xml Validator = new Xml Validating Reader(xml Markup, Xml Node Type. Validation Event Handler = new Validation Event Handler(Validation Handler); xml Validator. Add("", "test2005042101Xsd.xml"); where the first argument is "" for no namespace and where "test2005042101Xsd.xml" is the (relative) URL where the schema is.
After that you can use the Read method as in other examples. FAQTs.com/ this all makes sense, thanks again Martin.
Note that I didn't bother to put a string literal with XML into the program but read the XML from a file first to put it in a string then for the example: using System; using System. NET 1.1, the example XML markup in the string is being pulled in node by node and validation errors are reported. this demonstrated a few key concepts that i think the MSDN library was not making clear. i do not see anywhere that the Schema is being added to a Schema collection, and the validation type of the Validating Reader being changed to Schema? would you be willing to show how to add a Schema validation?
thanks again, jason i do have one question though about your example.
on last question about appropriate use of manual Schema addition: if you didn't control the source of the XML document, and could not be certain that it included the schema reference, would that be a good reason to add the Schema manually, to make certain it is validated using the schema?
my code is now reporting Schema errors with the manual schema addition.
thanks for any help, jason however, the Xml Validating Reader allows for another form of the constructor that doesn't have an underlying Xml Reader object.
you can pass in the entire XML string, as follows: Xml Parser Context o Context = new Xml Parser Context(null, null, null, Xml Space.
that's actually what i was working on before i made this thread, but it was producing unexpected results (i.e.None); // s Input contains an entire xml document string Xml Validating Reader o My VReader = new Xml Validating Reader(s Input, Xml Node Type.Document, o Context); but since you don't have use a Reader to acquire the XML document, how do you perform validation on the Xml fragment?nothing to read) do you happen to know a good book or online resource for showing an example of constructor passed XML fragments being DTD and Schema validated by an Xml Validating Reader?thanks for the previous comments, jason Here is an example I have made up now, the only special thing I had to do is to provide a base URI to the parser context so that the relative URI pointing to the schema could be resolved. Schema; public class Test2005042103 That example works fine for me here with .