The moose likes XML and Related Technologies and the fly likes Get the xml document's structure through the java code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Get the xml document Watch "Get the xml document New topic
Author

Get the xml document's structure through the java code

Ravi Khakhkhar
Greenhorn

Joined: Sep 01, 2011
Posts: 3



Now I want to convert this structure like this
books
-->book
------>book
----------->a
(Only skeleton , not data, with no repeat tags)
in a nested ArrayList or any other data structure through java code.

Can anyone suggest some direct methods of parser or API that can do this??




g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 225
Can google with keywords like "java traversal xml". I just do that to return only pages of last 12 months. This looks something close to what I have in mind using only jaxp bundled with standard jdk.
http://shivasoft.in/blog/java/traverse-xml-file-using-dom-parser-of-jaxp/
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 11862
If you parse the XML to a DOM (Document Object Model) you will have the structure and can manipulate it with the standard Java library.

Harold's free online book has plenty of examples.

Bill

Java Resources at www.wbrogden.com
 
 
subject: Get the xml document's structure through the java code
 
Threads others viewed
Well defined or generalized service contract?
JSTL SQL XML data source / driver?
Databinding - ADB and none
Good Book on Data Structures and Algorithms in Java
How to start learning XML, XSL, DOM and SAX?
developer file tools