tags:

views:

788

answers:

3

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.

+1  A: 

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.

mercator
I am unfortunately tied to version 2.0 due to preexisting code. I'll keep playing around with it now that I know I'm at least on the right track, thank you for taking a look Mercator.
James
Thank you for your help, I finally got some time to play around with it again.Do to programmer error (myself ans some key typos), a malformed DTD that was given to me, and lack of knowledge in this area I was just going around in circles. Fixed an working now, thanks.
James
Thanks! Glad you got it fixed.
mercator
A: 

I am unfortunately tied to version 2.0 due to preexisting code. I'll keep playing around with it now that I know I'm at least on the right track, thank you for taking a look Mercator.

James
How do I remove this answer? I've made it a comment of the previous answer.
James
You can delete it if you register... Or wait till someone with a lot more reputation than me comes by and deletes it:http://stackoverflow.com/questions/228462/how-can-a-question-or-answer-be-deleted
mercator
A: 

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

gkrogers