EDN Admin
Well-known member
<p align=left><font face=Arial size=2></font>
Hello,
<p align=left>I need to validate couple of XML files against a DTD file located in another folder. How do I do that? I tried this method. It didnt work. Am I missing anything here? <font size=2>
</font><font color="#2b91af" size=2></font>
<p align=left>xmlFileStream is the input xml stream here...
<p align=left>
<p align=left><font color="#2b91af" size=2>XmlReaderSettings</font><font size=2> settings = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>XmlReaderSettings</font><font size=2>();
settings.ProhibitDtd = </font><font color="#0000ff" size=2>false</font><font size=2>;
settings.ValidationType = </font><font color="#2b91af" size=2>ValidationType</font><font size=2>.DTD;
settings.ValidationEventHandler += </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ValidationEventHandler</font><font size=2> (ValidationCallBack);
settings.XmlResolver.ResolveUri(</font><font color="#a31515" size=2>"c:\folder\dtdFile.dtd"</font><font size=2>, </font><font color="#0000ff" size=2>null</font><font size=2>);
</font><font color="#008000" size=2>// Create the XmlReader object. </font><font size=2>
</font><font color="#2b91af" size=2>XmlReader</font><font size=2> reader = </font><font color="#2b91af" size=2>XmlReader</font><font size=2>.Create(xmlFileStream, settings);
</font><font color="#008000" size=2></font>
<p align=left><font color="#008000" size=2>// Parse the file. </font>
<p align=left><font color="#008000" size=2>try</font>
<p align=left><font color="#008000" size=2>{ </font><font size=2>
</font><font color="#0000ff" size=2>while</font><font size=2> (reader.Read()) ;</font>
<p align=left>}
<p align=left>
<p align=left>catch
<p align=left>{
<p align=left> --error
<p align=left><font size=2>} </font>
<p align=left>
<p align=left>Thanks,
<p align=left>SP
<p align=left>
View the full article
Hello,
<p align=left>I need to validate couple of XML files against a DTD file located in another folder. How do I do that? I tried this method. It didnt work. Am I missing anything here? <font size=2>
</font><font color="#2b91af" size=2></font>
<p align=left>xmlFileStream is the input xml stream here...
<p align=left>
<p align=left><font color="#2b91af" size=2>XmlReaderSettings</font><font size=2> settings = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>XmlReaderSettings</font><font size=2>();
settings.ProhibitDtd = </font><font color="#0000ff" size=2>false</font><font size=2>;
settings.ValidationType = </font><font color="#2b91af" size=2>ValidationType</font><font size=2>.DTD;
settings.ValidationEventHandler += </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>ValidationEventHandler</font><font size=2> (ValidationCallBack);
settings.XmlResolver.ResolveUri(</font><font color="#a31515" size=2>"c:\folder\dtdFile.dtd"</font><font size=2>, </font><font color="#0000ff" size=2>null</font><font size=2>);
</font><font color="#008000" size=2>// Create the XmlReader object. </font><font size=2>
</font><font color="#2b91af" size=2>XmlReader</font><font size=2> reader = </font><font color="#2b91af" size=2>XmlReader</font><font size=2>.Create(xmlFileStream, settings);
</font><font color="#008000" size=2></font>
<p align=left><font color="#008000" size=2>// Parse the file. </font>
<p align=left><font color="#008000" size=2>try</font>
<p align=left><font color="#008000" size=2>{ </font><font size=2>
</font><font color="#0000ff" size=2>while</font><font size=2> (reader.Read()) ;</font>
<p align=left>}
<p align=left>
<p align=left>catch
<p align=left>{
<p align=left> --error
<p align=left><font size=2>} </font>
<p align=left>
<p align=left>Thanks,
<p align=left>SP
<p align=left>
View the full article