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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 24082
54
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: 24082
54
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.
 
this is supposed to be a surprise, but it smells like a tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!