title: Better way to parse xml
body: <p>I've been parsing XML like this for years, and I have to admit when the number of different element becomes larger I find it a bit boring and exhausting to do, here is what I mean, sample dummy XML:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;Order&gt;
      &lt;Date&gt;2003/07/04&lt;/Date&gt;
      &lt;CustomerId&gt;123&lt;/CustomerId&gt;
      &lt;CustomerName&gt;Acme Alpha&lt;/CustomerName&gt;
      &lt;Item&gt;
          &lt;ItemId&gt; 987&lt;/ItemId&gt;
          &lt;ItemName&gt;Coupler&lt;/ItemName&gt;
          &lt;Quantity&gt;5&lt;/Quantity&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;ItemId&gt;654&lt;/ItemId&gt;
          &lt;ItemName&gt;Connector&lt;/ItemName&gt;
          &lt;Quantity unit="12"&gt;3&lt;/Quantity&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;ItemId&gt;579&lt;/ItemId&gt;
          &lt;ItemName&gt;Clasp&lt;/ItemName&gt;
          &lt;Quantity&gt;1&lt;/Quantity&gt;
      &lt;/Item&gt;
  &lt;/Order&gt;
  </code></pre>
  
  <p>This is relevant part (using sax) :</p>
  
  <pre><code>public class SaxParser extends DefaultHandler {
  
      boolean isItem = false;
      boolean isOrder = false;
      boolean isDate = false;
      boolean isCustomerId = false;
      private Order order;
      private Item item;
  
          @Override
      public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
          if (localName.equalsIgnoreCase("ORDER")) {
              order = new Order();
          }
  
          if (localName.equalsIgnoreCase("DATE")) {
              isDate = true;
          }
  
          if (localName.equalsIgnoreCase("CUSTOMERID")) {
              isCustomerId = true;
          }
  
          if (localName.equalsIgnoreCase("ITEM")) {
              isItem = true;
          }
      }
  
      public void characters(char ch[], int start, int length) throws SAXException {
  
          if (isDate){
              SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
              String value = new String(ch, start, length);
              try {
                  order.setDate(formatter.parse(value));
              } catch (ParseException e) {
                  e.printStackTrace();
              }
          }
  
          if(isCustomerId){
              order.setCustomerId(Integer.valueOf(new String(ch, start, length)));
          }
  
          if (isItem) {
              item = new Item();
              isItem = false;
          }
  
  
  
      }
  
  }
  </code></pre>
  
  <p>I'm wondering is there a way to get rid of these hideous booleans which keep growing with number of elements. There must be a better way to parse this relatively simple xml. Just by looking the lines of code necessary to do this task looks ugly. </p>
  
  <p>Currently I'm using SAX parser, but I'm open to any other suggestions (other than DOM, I can't afford in memory parsers I have huge XML files).</p>