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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
Rancher
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: 23707
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: 23707
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.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!