How to turn JSON to object literal using PHP and jquery
<p>Is there a concise neat way to turn an XML feed into an JavaScript object literal?</p>

<p>I have this XML feed</p>

<pre><code>&lt;jobs&gt;
    &lt;industry&gt;
        &lt;name&gt;Technology&lt;/name&gt;
        &lt;area&gt;Refrigiration&lt;/area&gt;
        &lt;area&gt;Information Technology&lt;/area&gt;
        &lt;area&gt;Electronics&lt;/area&gt;
        &lt;area&gt;Avionics&lt;/area&gt;
    &lt;/industry&gt;

    &lt;industry&gt;
        &lt;name&gt;Agriculture&lt;/name&gt;
        &lt;area&gt;Agri-Tourism&lt;/area&gt;
        &lt;area&gt;Animal Husbandry&lt;/area&gt;
        &lt;area&gt;Harvesting&lt;/area&gt;
        &lt;area&gt;Poultry&lt;/area&gt;
    &lt;/industry&gt;
&lt;/jobs&gt;
</code></pre>

<p>and wish to turn it to:</p>

<pre><code>var jobs = [
    {
        "name"  : "Technology",
        "areas" : [ "Refrigiration" , "Information Technology", "Electronics", "Avionics" ]
    },

    {
        "name"  : "Agriculture",
        "areas" : [ "Agri-Tourism" , "Animal Husbandry", "Harvesting", "Poultry" ]      
    },

    {
        "name"  : "Media",
        "areas" : [ "Journalism" , "Camera person", "Reality tv person", "Commentator" ]        
    }       
];
</code></pre>

<p>I succeeded in encoding the JSON object using php. What I am missing is the rest.</p>
