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 Android Security Essentials Live Lessons this week in the Android 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: 8904

document.getElementsByTagName ("*") return all tags

It is sorta covered in the JavaRanch Style Guide.
subject: XML DOM Document reading elements
Similar Threads
split big DOM xml file ??
Suggest a ideal XML API for large XML Files
Java-Xml file not getting Connected to DataBase
Help regarding how to check the element entered is equal or not in xml file
XML Tag modification