title: How do you traverse and store XML in Blackberry Java app?
body: <p>I'm having a problem accessing the contents of an XML document.
  My goal is this:
  Take an XML source and parse it into a fair equivalent of an associative array, then store it as a persistable object.</p>
  
  <p>the xml is pretty simple:</p>
  
  <pre><code>&lt;root&gt;
  &lt;element&gt;
      &lt;category_id&gt;1&lt;/category_id&gt;
      &lt;name&gt;Cars&lt;/name&gt;
  &lt;/element&gt;
  &lt;element&gt;
      &lt;category_id&gt;2&lt;/category_id&gt;
      &lt;name&gt;Boats&lt;/name&gt;
  &lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Basic java class below. I'm pretty much just calling save(xml) after http response above. Yes, the xml is properly formatted.</p>
  
  <pre><code>    import java.io.IOException;
      import java.util.Hashtable;
  
      import org.w3c.dom.Document;
      import org.w3c.dom.Node;
      import org.w3c.dom.NodeList;
  
      import java.util.Vector;
      import net.rim.device.api.system.PersistentObject;
      import net.rim.device.api.system.PersistentStore;
      import net.rim.device.api.xml.parsers.DocumentBuilder;
      import net.rim.device.api.xml.parsers.DocumentBuilderFactory;
  
  public class database{
          private static PersistentObject storeVenue;
          static final long key = 0x2ba5f8081f7ef332L;
          public Hashtable hashtable;
          public Vector venue_list;
          String _node,_element;
  
      public database()
      {
          storeVenue = PersistentStore.getPersistentObject(key);
      }
  
      public void save(Document xml)
      {
              venue_list = new Vector();
          storeVenue.setContents(venue_list);
  
  
          Hashtable categories = new Hashtable();
  
  
          try{
  
              DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory. newInstance();
              DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
              docBuilder.isValidating();
  
              xml.getDocumentElement ().normalize ();
  
              NodeList list=xml.getElementsByTagName("*");
              _node=new String();
              _element = new String();
  
              for (int i=0;i&lt;list.getLength();i++){
  
                  Node value=list.item(i).getChildNodes().item(0);
                  _node=list.item(i).getNodeName();
                  _element=value.getNodeValue();
  
                  categories.put(_element, _node);
              }
  
          }
          catch (Exception e){
              System.out.println(e.toString());
          }
  
          venue_list.addElement(categories);
  
  
          storeVenue.commit();
      }
  </code></pre>
  
  <p>The code above is the work in progress, and is most likely heavily flawed. However, I have been at this for days now. I can never seem to get all child nodes, or the name / value pair.
  When I print out the vector as a string, I usually end up with results like this:
  [{ = root, = element}]
  and that's it. No "category_id", no "name"</p>
  
  <p>Ideally, I would end up with something like
  [{1 = cars, 2 = boats}]</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks</p>