I am receiving an XML document from a REST service which shall be parsed using SAX. Please see the following example which was generated out of the XSD.
Setting up th
SAX parsers are a bit like looking at a large picture through a tiny spy hole.
The callback will present you with a single piece of the XML structure at a time. It wont give you any clues as to where you are in the document only a single piece of data is presented,. The element name, the attribute name/value or the text contents.
Your program needs to track where you are in the document. If you are parsing on the fly a simple stack structure will do -- you push the name onto the stack when you get a "beginelement" and you pop the stack on an "endelement".
If you find yourself building a tree structure I would switch to a DOM parser as whatever you write will be a pale and buggy shadow of something like XERCES.