PDA

View Full Version : Verifying XML loaded/saved



xtal256
5th March 2011, 08:17
Hi all.

I have an application and i want to save and load some data in it using xml (as you do). I could do that quite easily but i want to make sure the data is valid according to a DTD or something. That is, i want the xml document structure to be the same when writing the data from my application and when reading it in. Also, it will mean i don't have to do as much checking to make sure the structure is correct.

So my question is how to do this in Qt. I already know how to read an xml file into a QDomDocument, i just want to know about DTD or schema validation or whatever it is.

thanks

stampede
5th March 2011, 14:34
Have you seen this example (http://doc.qt.nokia.com/4.7-snapshot/xmlpatterns-schema.html) ? It shows how to use QXmlSchema (http://doc.qt.nokia.com/latest/qxmlschema.html) to validate xml document based on predefined schema.

xtal256
6th March 2011, 02:01
Yes, actually i have. But i am not sure what the difference is between xml schema and DTD. Also, i was wondering if i need to set/validate against a schema when creating and writing the xml. Or is that only necessary when reading it and i should just make sure my code writes the xml correctly?