Reading Writing XML in C++ 6.0
-
What is the best way to use XML in C++ 6.0? DOM or SAX, wich is the easiest and efficient way to read and write data. examples and comments welcome thanks
The DOM works well for small files, SAX for larger ones.
Jason Henderson
start page
articles
"If you are going through hell, keep going." - Sir Winston Churchill -
What is the best way to use XML in C++ 6.0? DOM or SAX, wich is the easiest and efficient way to read and write data. examples and comments welcome thanks
One more thing to consider with the DOM versus SAX, The DOM creates persistant data for your XML. It will read the data in and create an internal structure that you can refer back to whenever you need to read from a certain node. The SAX on the other hand is a one pass mechanism, where you will use the APIs to read and write the data. The data is not persistant in the SAX API so once it has been read, it is forgotten and you are responsible for persiting the data in your app.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
One more thing to consider with the DOM versus SAX, The DOM creates persistant data for your XML. It will read the data in and create an internal structure that you can refer back to whenever you need to read from a certain node. The SAX on the other hand is a one pass mechanism, where you will use the APIs to read and write the data. The data is not persistant in the SAX API so once it has been read, it is forgotten and you are responsible for persiting the data in your app.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!The downside with SAX is that you almost inevitably end up writing FSA style stuff to deal with the incoming data, and there's no support for navigating the document as in DOM. While writing a state machine isn't exactly rocket science, if you have never done it before there are many things to watch out for. Steve S [This signature space available for rent]