You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Supriya Shiyekar <su...@tek-tools.com> on 2001/11/13 23:57:32 UTC

SAX question from a beginner

Hi,

      How can I use SAX parser to retrieve values of two elements with same name which belong to different nodes?
For example....

<root>
<a>
   <field name=key value=12/>
</a>
......
......
<b>
   <field name=key value=14/>
</b>
</root>

How do I retrieve the two different values for the "key"?

If I have following in the startElement(...) method it will
overwrite the first value of "key"..

if (localName.equalsIgnoreCase("field"))  
  {
   String fieldName = attributes.getValue("name");
   if (fieldName.equalsIgnoreCase("key"))
   {
    key= attributes.getValue("value");
   }
}

Thanks for any Help,
Supriya.