An xml file would like similar to below.
<?xml version="1.0"?> <root> <words>one</words> <words>two</words> </root>
The first line, if present, could ignore at present, just save the version in a variable.
Idea of process,
1. Get element – add element name to a array stack (push)
2. get value if present.
3. if end of element then pop the array stack (array stack would be null in this instance)
repeat the above for the xml example above it would be
1. element = root, array stack = root
2. no value
3. not the end of element goto 1.
1 element = words, array stack = words, root.
2.value = one
3. end of element, pop stack, array stack = root (check popped stack in the same as the end element else ERROR.
always check for errors, e.g. end of file etc. and whilst going through the xml file, place the details into a object so that it can be “viewed” from within the c++ program.
this will just be a version 0.1 as such, a basic reader. if I carry it on then
version 0.2 would have attributes pull
version 0.3 xpath
and then version 0.4 other parts.. checking against version numbers etc.
Here is the two files together.
and to all join together and call
compile and run.