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 XML and Related Technologies and the fly likes XML DOM Document reading elements 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 » Engineering » XML and Related Technologies
Bookmark "XML DOM Document reading elements" Watch "XML DOM Document reading elements" New topic
Author

XML DOM Document reading elements

felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
hi,
Could anyone tell me how can i read XML DOM object and find out the element it contains .
document.getElementsByTagName is there but i have to give the tag name .
I there any other method we can fin out the elemts and their values without knowing the tag names.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
getChildNodes() gives you a list of all child nodes of the current node. If you're starting out from the root element, that's all you need to traverse the whole document.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

document.getElementsByTagName ("*") return all tags


Groovy
 
jQuery in Action, 2nd edition
 
subject: XML DOM Document reading elements