Output Validation in CSVToXMLBasic.cpp

There were a few idiosyncrasies with validating XML as input, but validating output can be downright tricky. I expected output validation to be a piece of cake, but it took me a couple of hours to figure out what was going on and to make it work correctly. Going through the exercise may help you understand a bit more about how MSXML does things.

The first time I coded the routine I just added a block of code to CSVToXMLBasic.cpp that was almost identical to the input validation snippet shown above in XMLToCSVBasic.cpp. It didn't work. I got a validation failure message indicating that “the root element had no associated DTD/schema.”

MSXML stores schemas internally and makes them available through the IXMLDOMSchemaCollection/XMLSchemaCache ...

Get Using XML with Legacy Business Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.