I am writing an XML parser in C++ using libxml library which requires me to validate the XML against a DTD which is specified inline. I don't want to use system() in my program. Otherwise I could have used the xmllint command.
I came across the xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) function specified in the http://xmlsoft.org/ API page. But I feel it is DOM based function since in SAX parsing there is no xmlDocPtr.
Are there are any other methods to validate the XML document against the inline DTD?
Usually, you simply provide the
XML_PARSE_DTDVALID
parser option, so the document will be validated when parsed.If the document has already been parsed without validation, you can use
xmlValidateDocument
: