aspose file tools*
The moose likes XML and Related Technologies and the fly likes Getting Node Values. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting Node Values." Watch "Getting Node Values." New topic
Author

Getting Node Values.

Sankar Madhavan
Greenhorn

Joined: Nov 19, 2008
Posts: 3
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 ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Node Values.