Array2Xml subarray getting looped instead of becoming parent array

     

I am trying to make a node in xml parent of all other nodes just that for some reason it becomes parent for each one instead of a parent global.


Current output - As you can see the data keeps getting repeated for each quiz.


    
         <![CDATA[Module 1]]>                  <![CDATA[Module 2]]>                  <![CDATA[Module 3]]>             

Expected Output - Data should remain parent array as it is in php like this.


    
         <![CDATA[Module 1]]>            <![CDATA[Module 2]]>            <![CDATA[Module 3]]>             

PHP Code + Array2XML Class