aspose file tools*
The moose likes XML and Related Technologies and the fly likes Printing values from a xml file 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 "Printing values from a xml file" Watch "Printing values from a xml file" New topic
Author

Printing values from a xml file

zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi,

I am a novice in xml. I am using jdk1.4. I need some idea on how to parse XML file using DOM Parser.

I have a file with the following contents:


Basically I want to iterate though the file using a DOM parser and bring the results back to my Java code. Currently, I have:


Can anyone please tell me why the value of the node 'Zahid Zubair' is not getting printed?


Thanks,
Zahid
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39551
    
  27
Your assumption about how the DOM tree is structured is incorrect. You may want to print out the type and name of the node you're inspecting.


Ping & DNS - updated with new look and Ping home screen widget
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi Ulf,

I hope this would be correct structure:



Please let me know what I am missing here:
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39551
    
  27
That's the XML structure; but the DOM tree structure is different than what you think it is. I suggest you iterate through the entire node list and print out node names, types and values. You should also consult the javadocs of the Node interface in order to learn what values nodes have for the various node types.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing values from a xml file
 
Similar Threads
XPath and Modified DOM document object...
Extract full path when parsing XML
Parsing XML file using Xpath in jdk1.4
a ReadXMLFile Servlet works without my expectation...
Getting all child element from root element