This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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 ]
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.