Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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


 
Rancher
Posts: 42975
76
  • 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.
 
Screaming fools! It's nothing more than a tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!