someone please help me do this...how to validate an xml file if the doctype is NOT specified! I have the DTD with me, but the I have to check XML files without the DOCTYPE or DTD
I already have to code to check when the DTD is specified but its gettting really confusing when the DTD is not specified. So please, someone help me achieve that.
Also, is there a way to get the root-element before i began anything? i ask because i want element names to be case insensitive
I already have to code to check when the DTD is specified but its gettting really confusing when the DTD is not specified. So please, someone help me achieve that.
Also, is there a way to get the root-element before i began anything? i ask because i want element names to be case insensitive
Code:
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.DTD;
settings.ValidationEventHandler += new ValidationEventHandler(MyValidationEventHandler);
// Create the XmlReader object.
XmlReader reader = XmlReader.Create(xmlFile, settings);
// Parse the file.
while (reader.Read()) ;
if (isValid)
{
Console.WriteLine("XML is VALID ");
}
static void MyValidationEventHandler(object sender, ValidationEventArgs args)
{
isValid = false;
Console.WriteLine("\nINVALID XML: " + args.Message);
}