When running the code below the validation fails when the first line of
my xml contains
<legalEnvelope version="1.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
If I change this line to
<legalEnvelope version="1.1">
It validated fine.
Anyone have any idea why this is?
The exact error this throws is:
An unhandled exception of type 'System.Xml.Schema.XmlSchemaException'
occurred in system.xml.dll
Additional information: System error.
===========CODE==================
XmlValidatingReader myVReader = null;
System.Xml.XmlDocument xd = new XmlDocument();
string f = @"C:\dev\batchUpload\xslt\sample.xml";
string dtdFileName =
@"C:\dev\bwiseley_eFile\vobEFile\EFM\Common\classe s\LegalXml\Xml\CLLegalXml.dtd";
xd.LoadXml(LNSea.IO.FileHelper.FileToString(f));
string myRootNodeName = xd.DocumentElement.Name; //
this.DocumentElement.Name;
XmlDocument myNewDom = new XmlDocument();
myNewDom.AppendChild(
myNewDom.CreateDocumentType(myRootNodeName,null,dt dFileName,null));
myNewDom.AppendChild(myNewDom.ImportNode(xd.Docume ntElement,true));
myVReader = new XmlValidatingReader(new XmlTextReader(new
StringReader(myNewDom.InnerXml)));
myVReader.ValidationType = ValidationType.DTD;
while(myVReader.Read());