• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Node Values.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used the following code to parse the xml and generate the details of an order. But once in a while when parsing and creating the DTO the values of some objects are assigned to wrong. Could any one let me know if anything is to added as part of code to make sure that the correct value is assigned to correct object.




[Edited to use code tags - Paul Sturrock]
[ November 19, 2008: Message edited by: Paul Sturrock ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you dont say what is "wrong" - I am going to guess that the problem is here:



There is NO guarantee that the entire string of text will be captured here. See the API javadocs. The characters() method may be called many times in the course of parsing a single Text node. It is up to the programmer to capture the text - typically in a StringBuffer - and only create a String when the endElement() event is fired.

The reason is that the parser reads blocks of characters for efficiency. If a text field extends past the block end, you only get that part when characters() is called.

Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic