• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Get the xml document's structure through the java code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic