Question

I am attempting to write a XML parser in VB6.
The standards that the XML is based off of comes with a DTD to verify the XML before you begin parsing. I have also written a sample XML file so that I have something with which to test.

I am able to load the XML via the vb6 code

Dim objXMLDoc As MSXML.DOMDocument
Set objXMLDoc = New MSXML.DOMDocument  
If Not objXMLDoc.Load("sample.xml") Then  
----Goto ErrorHandler  
End If

Working XML

<?xml version = "1.0"?>  
<Root>  
...  
</Root>

Trying to validate with my DTD

<?xml version = "1.0"?>  
<!DOCTYPE sample SYSTEM "sample.dtd">  
<Root>  
...  
</Root>

The research I did lead me to believe that the Load would validate the XML if the XML pointed to the DTD via the doc type.
I've done a lot of research and cant figure out where I'm going wrong. It could be as simple as the DTD provided isn't syntactically correct, which I'm looking over now. The resources I've found are mostly on MSDN and here http://www.jalix.org/ressources/internet/dom/~vrac/articles/XML%20DOM.html.
Both the xml and dtd are located in the same directory, and I have it parsing the XML with out the doctype tag.

The error I get is:
Error #: -2146697211: The system cannot locate the resouce specified. error processing resource 'sample.dtd'

Any additional resources, or suggestions would be greatly appreciated.

Was it helpful?

Solution

I can't reproduce your error. It works just fine with both files in the same folder for me.

It's not a problem of the DTD not being well-formed either; that throws another error. I get the same error as you if it can't find the DTD, while I get error -1072896757 ("Invalid character found in DTD.") if it does find my (totally bogus) DTD.

Have you tried using a different Microsoft XML version, or are you tied to the old version 2.0? Try v6.0 if possible.

OTHER TIPS

an obvious suggestion, but have you tried fully qualifying the dtd filename (i.e c:\blahblah...\sample.dtd?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top