I have an xml file is like this
<WORLD>
<COUNTRY COUNTRYID="INDIA">
<STATE STATEID="ANDHRAPRADESH">
<CITY>HYDERABAD</CITY>
<CITY>VIZAG</CITY>
<CITY>KURNOOL</CITY>
</STATE>
<STATE STATEID="TAMILNADU">
<CITY>CHENNAI</CITY>
<CITY>COIMBATORE</CITY>
<CITY>SALEM</CITY>
</STATE>
<STATE STATEID="KARNATAKA">
<CITY>BANGALORE</CITY>
<CITY>MYSORE</CITY>
<CITY>BALLARI</CITY>
</STATE>
</COUNTRY>
<COUNTRY COUNTRYID="AUSTRALIA">
<STATE STATEID="NEW SOUTH WALES">
<CITY>PERTH</CITY>
<CITY>BRIABANE</CITY>
<CITY>HOBART</CITY>
</STATE>
</COUNTRY>
</WORLD>
i want to display expandable/collapse tree structure using xsl and javascript(if necessary) with plus and minus signs;
> WORLD | |
> INDIA
> |
> |
> ANDHRAPRADESH
> |
> |
> HYDERABAD
> VIZAG
> KURNOOL
> KARNATAKA
> |
> |
> BANGALORE
> BALLARI
> AUSTRALIA
> |
> |
> NEW SOUTH WALES
> |
> |
> PERTH
> BRIABANE
Is it possible simply with XSL and maybe some javascript or pure CSS?
I have a general form of this problem, though I did pinch the sample XML shown above from
Essentially I would very much like to end up with something as cool as this, but just using XSL (and a little javascript if necessary) to transform my XML document. Any ideas?
Note:I have precious little experience with XSL or javascript, I do use python a bit so if there's a python library or solution please let me know
Assuming you want to use that code in the link you gave here is an example stylesheet that creates the nested, unordered
ul
list structure and simply reuses the Javascript and CSS code and images from the sample you linked to, in the real case you might want to copy the images and put them on your server:The XML document then simply refers to above XSLT with