I am a bit novice in JS and drafting a JS code to parse and create a HighChart options structure. The XML file has content in following format

Series->DrillDown->Data->Series->DrillDown->Data...

The last 'Data' branch will have 'point' node. Below is the XML (filename: ex.xml) file I receive as an AJAX call made via Jquery:

Code:
    <chart>
         <categories>
            <name>'MSIE'</name>
            <name>'Firefox'</name>
            <name>'Chrome'</name>
            <name>'Safari'</name>
            <name>'Opera'</name>
          </categories>
          <name>'Browser Brands'</name>
          <data>
                 <series>
                   <y>55.11</y>
                   <drilldown>
                      <name>'MSIE versions'</name>
                      <categories>
                          <name>'MSIE 8.0'</name>
                          <name>'MSIE 6.0'</name>
                          <name>'MSIE 7.0'</name>
                          <name>'MSIE 9.0'</name>
                      </categories>
                     <data>
                         <series>
                           <y>33.06</y>
                           <drilldown>
                               <name>'drilldown next level'</name>
                                <categories>
                                  <name>'a'</name>
                                  <name>'b'</name>
                                  <name>'c'</name>
                                </categories>
                                <data>
                                  <point>23</point>
                                  <point>54</point>
                                  <point>47</point>
                                 </data>
                           </drilldown>
                         </series>
                       <point>10.85</point>
                       <point>7.35</point>
                       <point>2.41</point>
                     </data>
                   </drilldown>
                 </series>
                 <series>
                   <y>21.63</y>
                    <drilldown>
                    <name>'Firefox versions'</name>
                    <categories>
                        <name>'Firefox 3.6'</name>
                        <name>'Firefox 4.0'</name>
                        <name>'Firefox 3.5'</name>
                        <name>'Firefox 3.0'</name>
                        <name>'Firefox 2.0'</name>
                    </categories>
                     <data>
                        <point>13.52</point>
                        <point>5.43</point>
                        <point>1.58</point>
                        <point>0.83</point>
                        <point>0.20</point>
                     </data>
                   </drilldown>
                 </series>
                 <series>
                   <y>11.94</y>
                   <drilldown>
                    <name>'Chrome versions'</name>
                    <categories>
                       <name>'Chrome 10.0'</name>
                       <name>'Chrome 11.0'</name>
                       <name>'Chrome 8.0'</name>
                       <name>'Chrome 9.0'</name>
                       <name>'Chrome 12.0'</name>
                       <name>'Chrome 6.0'</name>
                       <name>'Chrome 5.0'</name>
                       <name>'Chrome 7.0'</name>
                    </categories>
                    <data>
                       <point>9.91</point>
                       <point>0.50</point>
                       <point>0.36</point>
                       <point>0.32</point>
                       <point>0.22</point>
                       <point>0.19</point>
                       <point>0.12</point>
                       <point>0.12</point>
                   </data>
                   </drilldown>
                   </series>
                   <series>
                   <y>7.15</y>
                   <drilldown>
                   <name>'Safari versions'</name>
                   <categories>
                       <name>'Safari 5.0'</name>
                       <name>'Safari 4.0'</name>
                       <name>'Safari Win 5.0'</name>
                       <name>'Safari 4.1'</name>
                       <name>'Safari/Maxthon'</name>
                       <name>'Safari 3.1'</name>
                       <name>'Safari 41'</name>
                   </categories>
                   <data>
                       <point>4.55</point>
                       <point>1.42</point>
                       <point>0.23</point>
                       <point>0.21</point>
                       <point>0.20</point>
                       <point>0.19</point>
                       <point>0.14</point>
                   </data>
                </drilldown>
               </series>
               <series>
                  <y>2.14</y>
                   <drilldown>
                   <name>'Opera versions'</name>
                   <categories>
                      <name>'Opera 11.x'</name>
                      <name>'Opera 10.x'</name>
                      <name>'Opera 9.x'</name>
                   </categories>
                    <data>
                       <point>1.65</point>
                       <point>0.37</point>
                       <point>0.12</point>
                     </data>
                    </drilldown>
                </series>
            </data>
    </chart>
Now I am writing the JS code to parse and set the HighChart options. The objective is to set chart options to something like below :

Code:
    struct Series{
        float y:
        struct DrillDown{
            char name[SIZE];
            char categories[SIZE][SIZE];
            struct Data{
                struct Series * series;
                float points[SIZE];
            };
        };
    };
Code:
    struct Series seriesOptions;

As in XML tree structure format. This Series structure would then be set as HighChart options:

Code:
    options.series.push(seriesOptions);
where options is already defined array in the JS script.

So I traverse thru XML tree for each Series->for each DrillDown->for each Data->if series is there then traverse repetative Series->for each DrillDown->for each Data->set Data points:

Code:
    $.get('ex.xml', function(xml) {
                        var $xml = $(xml);
                        $xml.find('chart categories name').each(function(i, category) {
                                options.xAxis.categories.push($(category).text());
                        });
                        chart.setTitle.push($xml.find('chart name').text());
                        $xml.find("chart data series").each(function(i, series){
                                                var seriesDownSearch = function(){
                                                        var series = $(this);
                                                        var seriesOptions = {
                                                                y: parseInt(series.find('y').text()),
                                                                drilldown : []
                                                                }
                                                        series.find("drilldown").each(function(i, drilldown){
                                                                //set drilldown name leaf,categories branch name leaf and data branch
                                                                $(drilldown).find("data").each(function(i, data) {
                                                                        //set data point and loop if series branch is present
                                                                        $(data).find("series").each(seriesDownSearch);
                                                                });
                                                        })
                                                }();
                       });
    });
My issue is that how I set and create the commented code as //. Note that 'name leaf, categories branch name leaf and data branch' has to be an element of 'drilldown' and 'option' of 'data' element defined in 'drilldown'. Such that they can be accessed under one structure.

Thanks in advance