• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Sax Parsing startElement() method automatically create different object to avoid overwrite variable

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cant understand the problem regarding when following startElement method is called then it's start to read from< laptop> tag and crate object Laptop laptop1=new Laptop() and set the value into endElement method to Bean class. but what hapeen in Line 1 I marked at below means second <Lenovo> tag it's reached to read. the Another Different object must be crated i.e Laptop laptop2=new Laptop() to avoid over wright variable value. thanks in advance.

-->> Laptop.xml

Posts: 43016
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think line 7 should read "laptop = new Laptop()" instead of "laptop1 = new Laptop()" - you're not using "laptop1" anywhere else.
    Bookmark Topic Watch Topic
  • New Topic