I have:
<nodes>
<node>
<name>node1</name>
<other>stuff1</other>
<node>
<name>node11</name>
<other>stuff11</other>
</node>
<node>
<name>node12</name>
<other>stuff12</other>
</node>
</node>
<node>
<name>node2</name>
<other>stuff2</other>
</node>
<node>
<name>node3</name>
<other>stuff3</other>
</node>
</nodes>
I want to end up with a flat structure like:
<nodes>
<node>
<name>node1</name>
<other>stuff1</other>
</node>
<node>
<name>node11</name>
<other>stuff11</other>
</node>
<node>
<name>node12</name>
<other>stuff21</other>
</node>
<node>
<name>node2</name>
<other>stuff2</other>
</node>
<node>
<name>node3</name>
<other>stuff3</other>
</node>
</nodes>
This is a simple example but I want to copy all elements in each node, but not the nested ‘node’ elements. I tried the copy-of to preserve the tags but that also preserves the nesting. I also tried copy but that leaves out all children.
Any ideas?
This should do what you’re after. For the top-level
nodeselement it applies templates for all descendantnodeelements in document order. For eachnodeit copies all the non-nodechild elements.