I want to output something similar to the following using XSLT
XML:
<myroot>
<node1>
<subnode1>somestuff</subnode1>
<subnode2>otherstuff</subnode2>
</node1>
<node2>
<subnode2></subnode2>
<subnode3>stuff here</subnode3>
</node2>
<node3>
<subnode>stuff</subnode>
<subnode>stuff</subnode>
<subnode>other</subnode>
</node3>
</myroot>
Where I do not know the node names for a given instance.
I want my output to look like this:
myroot = new jsonObject();
myroot.node1 = new jsonObject();
myroot.node1.subnode1 = "holder";
myroot.node1.subnode2 = "holder";
myroot.node2 = new jsonObject();
myroot.node2.subnode2 = "holder";
myroot.node2.subnode3 = "holder";
myroot.node3 = new jsonObject();
myroot.node3.subnode = new array();
"arraystart"
myroot.node3.subnode[aindex] = new jsonObject();
myroot.node3.subnode[aindex] = "holder";
"endarray"
Important points:
- = "holder"; can be anything unique as I will change this later
- "arraystart" and "endarray" can be anything unique as I will change this later
- I do NOT know the specific node names beyond the root.
- I do NOT know the depth of the tree (some 6-7 deep exist)
- I do NOT know the numbers or position or array elements, but the child nodes(elements) are the same name for those groups.
- Multiple arrays may/do exist, and can be at any tree depth.
- Elements with text do not have child nodes