Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validating an XML file against a DTD

Status
Not open for further replies.

arielt

Programmer
Feb 20, 2001
4
0
0
IL
Hello all!
I'm trying to validate an XML file against a DTD using Microsoft DOM in C++.
I do something like:

IXMLDOMDocumentPtr pDTDDoc = NULL;
pDTDDoc.CreateInstance(CLSID_DOMDocument);

pDoc->load("D:\A.xml");

// Add the DTD header
_bstr_t TheXmlString = &quot;<!DOCTYPE RuleSet SYSTEM 'D:\\Dtd\\RuleSet.dtd'>&quot;
+ pDoc->GetfirstChild()->Getxml();

// Validate
pDTDLoadedDoc->PutresolveExternals(true);
pDTDLoadedDoc->PutvalidateOnParse(true);
pDTDLoadedDoc->loadXML(TheXmlString);

_bstr_t Error = pDTDLoadedDoc->GetparseError()->GeterrorCode();

And the error is allways 0, even when the XML does not follows the DTD rules.
Someone knows why and what to do?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top