This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Double xml read Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Double xml read" Watch "Double xml read" New topic
Author

Double xml read

Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

Hey,

I have an xml string and am doing a system out to see the results. The only issue use I keep getting duplicate results! why is this





Here is an example of my output:


Element tagname : client
getcharactervalue: website
..................................
Element tagname : client
getcharactervalue: website
..................................
Element tagname : request
getcharactervalue: insert
..................................
Element tagname : request
getcharactervalue: insert
..................................
Element tagname : databaseschema
getcharactervalue: barapplication
..................................
Element tagname : request
getcharactervalue: insert
..................................
Element tagname : table
getcharactervalue: ownerAddress
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Move lines 13-15 to before the loop; they are called for the node itself, not the child nodes.
Be warned though that the cast to Element may fail; whitespace like line breaks are often seen as Text nodes, and will show up in the child node list.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: Double xml read