validating xml against DTD

From: Wade G (wadegillingham_at_chartermi.net)
Date: 06/28/04


Date: Mon, 28 Jun 2004 05:23:09 -0700

I am using the following code to validate an xml file
against a DTD. If the xml file doesn't contain the
inline statement to declare the dtd, some xml files won't
show as invalid using this code. My question is, how do
I force the requirement to declare the DTD in the XML
file?

Private Function validate() As Boolean
 'open the xml filename to a XmlValidatingReader object
 Dim tr As XmlTextReader = New XmlTextReader(m_filename)
 Dim vr As XmlValidatingReader = New XmlValidatingReader
(tr)
 'validate against the DTD
 vr.ValidationType = ValidationType.DTD
 Try
  'read the file one node at a time
  While (vr.Read())
  End While
  Return True 'file is valid if this line is reached
 Catch
  Return False
 End Try
End Function



Relevant Pages

  • Problem with DTD declaration
    ... I have a DTD. ... If I declare it at the top of my XML file, ... If I remove - or comment out - the DTD declaration line the transform ...
    (comp.text.xml)
  • Re: Specifying a DTD for a DOMDocument
    ... against a DTD if load the XML file. ... Seems that the validate() function only works when loading xml files. ...
    (comp.lang.php)
  • Re: How to read an XML file in Visual C++ 6
    ... the DTD could be part of the XML file itself ... I'd vote for putting it in the resources. ... It makes no sense to put a remote URL into a file which is going to be used locally. ...
    (microsoft.public.vc.mfc)
  • Serializing from XML with remote DTD
    ... I have an XML file which I am serializing into a class using the ... the XML file has a dtd in it that points to a remote ... mean, it's not trying to validate it, so why ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Convert flat file to XML document
    ... >I am a newbee and have a comma seperated flat-file and a DTD. ... >XML file as per the the definition in the DTD. ... As required add extra processing to your program so that you can ... The ultimate truth is that there is no ultimate truth ...
    (microsoft.public.dotnet.languages.csharp)

Quantcast