5 Replies Latest reply on Oct 22, 2007 2:02 PM by 807603

    Storing identical XML tag values in an Object

    807603
      Hello,

      I've got an XML page which has several instances of the same tag, like this:

      <choice>
      <value>
      <code>1</code>
      <description>One</description>
      </value>
      <value>
      <code>2</code>
      <description>Two</description>
      </value>
      <value>
      <code>3</code>
      <description>Three</description>
      </value>
      <value>
      <code>4</code>
      <description>Four</description>
      </value>
      </choice>

      I can parse the values out of the XML page using SAX. The problem I have is how to store the values in a Java Object subsequently. I previously used a HashMap to store the XML tag as the key and the value as the mapped value, but of course now that I have multiple key values, they are being overwritten by each subsequent identical tag value.

      Does anyone have any suggestions as to how I can store these key/value pairs in an Object, keeping each that I parse from the XML?

      Thanks for any thoughts.