Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes XML and Related Technologies and the fly likes Why I can't retrieve records stored in a XMLFile correctly? 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 "Why I can Watch "Why I can New topic
Author

Why I can't retrieve records stored in a XMLFile correctly?

Mellihoney Michael
Ranch Hand

Joined: Nov 27, 2002
Posts: 124
Why I can't retrieve records stored in a XMLFile correctly?
ReadXMLFile.java

the xml file is:
address.xml

the output:

----------------------------------------------------------------------
But the output is supposed to be

can anyone help to explain me?
[ January 14, 2004: Message edited by: Mellihoney Michael ]

a beginner in java
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
The #text tags are the closing tags of your nodes.
If you want to work with XML, I'd recommend learning to use SAX and JDOM.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
You are seeing a lot of text nodes that contain the crlf and spaces of your formatted XML. Rather than index through the child nodes, consider use of the getElementsByTagName method to go directly to the Elements you want.
Bill
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I am going to move this thread to the XML forum. This forum is for Servlet questions.
Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
GeeCON Prague 2014
 
subject: Why I can't retrieve records stored in a XMLFile correctly?