Hai All,
I have got a problem in using SAX parser.
My XML looks like this:
-----------------------
<authorizer>
<first-name>HP</first-name>
<last-name>Services</last-name>
<phone>800-22-1984</phone>
</authorizer>
<destination>
<first-name>John</first-name>
<last-name>Doe</last-name>
<company>John Doe Enterprises, Inc.</company>
<department>Manufacturing</department>
<phone>800-555-1234</phone>
<address>
<street-one>1654 Peachtree Str</street-one>
<street-two>Suite Y</street-two>
<city>Atlanta</city>
<province>GA</province>
<country>US</country>
<postal-code>30326</postal-code>
</address>
</destination>
my part of SAX parser code is:
------------------------------
public void startElement (
String name, AttributeList attrs)
throws SAXException
{
accumulator.setLength(0);
}
public void characters (char buf [], int offset, int len)
throws SAXException
{
accumulator.append(buf, offset, len);
}
public void endElement (String name)
throws SAXException
{
if (name.equals("first-name") )
{
firstname=accumulator.toString().trim();
}
if (name.equals("last-name"))
{
lastname=accumulator.toString().trim();
}
}
My problem is that i have to store the values of first-name and last-name.
but i have that in both
<authorizer> </authorizer> Tag and
<destination> </destination>
I need to retrive authorizer's firstname,lastname and
destination's firstname and lastname.
what i mean is i need to store authorizerFirstName,authorizerLastName
destinationFirstname and destinationLastname.
Pls let me know how to do that.
Thanks in advance.
Pooja.