I’m trying to take a xml document and transform to a standard html list with nesting:
Sample
<orgtree>
<Node nodeID="1363" nodeDescription="Some User" nodeNote="Some Note" X="5260" Y="20">
<Node nodeID="1373" nodeDescription="Some Child User" nodeNote="More">
<Node nodeID="1374" nodeDescription="Another Child" nodeNote="More"/>
<Node nodeID="1375" nodeDescription="Another Child" nodeNote="More"/>
<Node nodeID="1376" nodeDescription="Another Child" nodeNote="More"/>
<Node nodeID="1377" nodeDescription="Another Child" nodeNote="More"/>
</Node>
<Node nodeID="1474" nodeDescription="Another Child" nodeNote="More"/>
<Node nodeID="1475" nodeDescription="Another Child" nodeNote="More"/>
</Node>
</ogtree>
I’d Like it to appear as:
<ul>
<li>Some User<br/>SomeNote
<ul>
<li>Some Child User<br/>More
<ul>
<li>Another Child<br/>More</li>
<li>Another Child<br/>More</li>
<li>Another Child<br/>More</li>
<li>Another Child<br/>More</li>
</ul>
<li>Another Child<br/>More</li>
<li>Another Child<br/>More</li>
</ul>
</li>
</ul>
Note: The Tree Can go on nesting forever, and each node can have multiple children. I’d like to display the ul li the same way and I am as of yet unable to do this…Can someone give me a better way to transform? Each Node also have a graphical position for page viewing an image based on the node id. (Though, I could care about this portion).
This is a basic setup for a XSLT you would need.
It has a template that matches any
Nodeelement and applies this template for any of its children incase it has anytest="Node". This technique is known as recursionWhen learning XSLT I can recommend the MSDN library for basic and advanced topics and w3schools for basics.