• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Convert string of XML tree into actual collapsible XML Tree, and then display on html ?

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used HTML5 file reader and dom parser to read in an xml file and parse the data. Using the resulting tree I got from the reader
I now am looking for a way to convert this string back into a collapsible XML tree structure. Is there any options for doing this without
using any third party libraries, or if I need a third party library, can you recommend me one?

So imagine this is my XMl



I'm looking to be able to display it like this on the html page and that I can collapse the whole lot or portion.
 
sean cronin
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I was using innerHTML to set the XML text which I now realize was wrong, so can get the XML displaying which is good. Just need some recommendations for
making it collapsible if possible.

Cheers.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure that there are plenty of jQuery plugins to do this sort of thing if you search for them. And of course, you could write such code yourself if you wanted to.

Another approach would be to just display the XML file in an iframe -- most browsers will display it as collapsible markup.
 
sean cronin
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks man, I'll look into them.
 
sean cronin
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to get this working using jstree. Documentation for it isn't the best but one small example got me going. Here's my solution:



Thanks again.
 
sean cronin
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code is not meant to be blue... It does work!
 
I want my playground back. Here, I'll give you this tiny ad for it:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic