Generate XML from oracle11 DB



I need to generate xml format given below from an oracle 11 database. All tag names are static strings. Data for nodes D1, D2, D3 etc I am able to get in a single query using a 2 table join.


If I use XMLElement("Node1", XMLElement("Node2",XMLElement("Node3",XMLElement("D1", ..... then even Node1, Node2 is getting returned with each row of data. I need Node1 and Node2 only once open at top and close at bottom. Any idea how can I do that?



<Node1>
<Node2 key = "XYZ">
<Node3>
<D1> R1F1 </D1>
<D2> R1F2 </D2>
<D3> R1F3 </D3>
</Node3>
<Node3>
<D1> R2F1 </D1>
<D2> R2F2 </D2>
<D3> R2F3 </D3>
</Node3>
<Node3>
<D1> R3F1 </D1>
<D2> R3F2 </D2>
<D3> R3F3 </D3>
</Node3>
</Node2>
</Node1>

No comments:

Post a Comment