File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML DOM Document reading elements" Watch "XML DOM Document reading elements" New topic

XML DOM Document reading elements

felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
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

Joined: Jan 23, 2002
Posts: 11962
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: 8927

document.getElementsByTagName ("*") return all tags

I agree. Here's the link:
subject: XML DOM Document reading elements
It's not a secret anymore!