• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
viral thakar
Greenhorn
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


 
Ulf Dittmer
Rancher
Posts: 42969
73
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic