• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Get the xml document's structure through the java code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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??




 
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic