title: Create PHP variables with data contained in a XML node
body: <p>I'm having some serious trouble with this. What I'm trying to do is 'extract' all the contents of a specific node in XML, and turn these into PHP variables, in order to use them later on.</p>
  
  <p>Heres a small sample XML test data set I'm using.</p>
  
  <pre><code>&lt;RECIPES&gt;
  &lt;RECIPE&gt;
  &lt;TI&gt;Cinnamon Rolls&lt;/TI&gt;
  &lt;IN&gt;1/2 ea Sweet dough mixture&lt;/IN&gt;
  &lt;IN&gt;1/2 c Packed light brown sugar&lt;/IN&gt;
  &lt;IN&gt;1/2 c Pecans; chopped&lt;/IN&gt;
  &lt;IN&gt;1/2 c Dark seedless raisins&lt;/IN&gt;
  &lt;IN&gt;1 tsp Ground cinnamon&lt;/IN&gt;
  &lt;IN&gt;1/4 c Butter OR margarine; melted&lt;/IN&gt;
  &lt;IN&gt;Sugar Glaze (below opt)&lt;/IN&gt;
  &lt;PR&gt;Some Stuff.&lt;/PR&gt;
  &lt;/RECIPE&gt;
  &lt;RECIPE&gt;
  &lt;TI&gt;SWEET BISCUITS&lt;/TI&gt;
  &lt;IN&gt;2 c Baking mix&lt;/IN&gt;
  &lt;IN&gt;2/3 c Milk&lt;/IN&gt;
  &lt;IN&gt;1/4 c Cinnamon Sugar&lt;/IN&gt;
  &lt;IN&gt;2 tb Butter&lt;/IN&gt;
  &lt;PR&gt;Some other stuff&lt;/PR&gt;
  &lt;/RECIPE&gt;
  &lt;RECIPE&gt;
  </code></pre>
  
  <p>(Theres actually about 900's of these)
  What I want to achieve is to extract the data from each  node, and convert them to a variable; Below is what I hope to end up with.</p>
  
  <pre><code>$variable="Cinamon Rolls";
  $variable2="Sweet Biscuits";
  </code></pre>
  
  <p>Is there a way to accomplish this? From what I've been researching i'm pretty sure it's something to do with SimpleXML. I've managed to output the  contents individually, but  just can't figure out how to then store them.</p>
  
  <p><strong>Problem is solved</strong>
  Thanks everyone for the help,</p>
  
  <pre><code> $obj = simplexml_load_string($xml);
  
      foreach($obj-&gt;RECIPE as $r) {
          $variable = (string)$r-&gt;TI;
          echo $variable; }
  </code></pre>
  
  <p>Superb, thanks very much. Saved my ass.</p>