I am not sure what exactly you are trying to develop. As assumption is that you want to create nested HTML field set (which is normally used for grouping of elements) based on the lay out described on your xml.
You may construct an intermediate xml document object (temporarily) from the xml that you gaven here. It is pretty easy. Use some recursive function to traverse through all elements of the given layout xml and generate the modified xml as follows.
<Groups>
<Group Name="Group1" ID="D7EBC5D6-0E6D-499E-B528-34BE14382755">
<Group Name="Group2" ID="CC012258-14AC-44E9-BA0F-78AE7C569FCB"/>
<Group Name="Group3" ID="E23D7E3B-9DDA-408E-9CC9-9AC1A9E36DD3"/>
</Group>
</Groups>
Once this is done, you could construct the nested fieldset HTML easily.
<fieldset>
<legend>Group1</legend>
<fieldset>
<legend>Group2</legend>
</fieldset>
<fieldset>
<legend>Group3</legend>
</fieldset>
</fieldset>
You may do some other customization if you want. Intermediate xml construction is not mandatory. You may directly construct the fieldset HTML from your lay out xml. But if you have to create this many times, then you may cache the intermediate xml.
Cheers,