title: What pattern should I use for using a SAX parser?
body: <pre><code>&lt;xml&gt;
  &lt;Office prop1="prop1" prop2="prop2"&gt;
      &lt;Version major="1" minor="0"/&gt;
      &lt;Label&gt;MyObjectA&lt;/Label&gt;
      &lt;Active&gt;No&lt;/Active&gt;
  &lt;/Office&gt;
  &lt;Vehicle prop="prop"&gt;
      &lt;Wheels&gt;4&lt;/Wheels&gt;
      &lt;Brand&gt;Honda&lt;/Brand&gt;
      &lt;Bought&gt;No&lt;/Bought&gt;
  &lt;/Vehicle&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>My XML is in this format. I am using a SAX parser to parse this file as the size of the xml file can be large.</p>
  
  <p>What pattern should I follow to parse the file.</p>
  
  <p>Usually I have been following this approach:</p>
  
  <pre><code>//PseudoCode
  if(start){
      if(type Office)
      {
         create an instance of type Office and populate the attributes of Office in the Office class using a call back
      }
      if(type Vehicle)
      {
         create an instance of type Vehicle and populate the attributes of Vehicle in the Vehicle class using a call back
       }
  }
  
  if(end){
       // do cleaning up
  }
  </code></pre>
  
  <p>This approach usually makes my parsing function containing start and end tag to be huge.
  Is there any other better approach which can be followed.</p>