Win a copy of Spring in Action (5th edition) this week in the Spring forum!
    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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How to create a hierarchy using the following xml file  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi friends.

I have an XML file in the following format



The name tag represents the element and the source represents where I have to place the name tag.
I need to build a hierarchy in the following manner.



There can be 'n' level hierarchy with child elements. How to create a hierarchy in java?

Can you advice on this.

Thanks
Bala
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Perhaps I am not understanding what you need, but I find it perfectly feasible to parse an XML document into a DOM and then use the DOM as the only representation of the data I need. This preserves the hierarchy of the original document and if you modify the data you can transform it back to a new XML file.

Bill
 
Sheriff
Posts: 23867
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm not understanding either. It would help if you explained what "build a hierarchy" means.

And from your example it looks like your text nodes contain (from the XML standpoint) a hidden structure which you have to decipher. Splitting text based on a delimiter doesn't have anything to do with XML; just get the text out of the XML and do what you have to do with it.
 
Paul Clapham
Sheriff
Posts: 23867
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
Let's have all of the conversation about this topic on a single thread. This one here: http://www.coderanch.com/t/472449/Java-General/java/create-hierarchy-using-following-xml

I will close this thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!