title: php explode on xml file
body: <p>Here is the xml file I have. ( I do not have editing abilities of the parser that creates this file... so hince why I am asking my question below).</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;JobSearchResults LookID="arkansas"&gt;
  &lt;!-- Served from qs-b-02.oc.careercast.com --&gt;
  &lt;QueryString&gt;clientid=arkansas&amp;amp;stringVar=xmlString&amp;amp;pageSize=200&amp;amp;searchType=featured&amp;amp;outFormat=xml&lt;/QueryString&gt;
  &lt;channel&gt;
  &lt;title&gt;JobsArkansas Listings&lt;/title&gt;
  &lt;items&gt;&lt;/items&gt;
  &lt;/channel&gt;
  &lt;item&gt;
       &lt;JobID&gt;73451732&lt;/JobID&gt;
       &lt;Title&gt;Radiology&lt;/Title&gt;
       &lt;Employer&gt;Baptist-Health         &lt;/Employer&gt;
       &lt;Location&gt;LITTLE ROCK, AR&lt;/Location&gt;
       &lt;Description&gt;&lt;![CDATA[IMMEDIATE OPENINGS for:Diabetes Patient Educator, RN Community Education Nurse-RN Baptist Health Community Outreach•Diabetes Patient Educator, RN: Full-time: 8am-5pm Minimum Requirements:•Requires graduation from a state approved school/college of Nursing•Current licensure by theAR State Board of Nursing. •2+ years bedside experience preferred. •Certified Diabetes Educator certificate preferred. •Community Education Nurse - RNMinimum Requirements (PRN: Varies):•Current RN license &amp; 2 years clinical experience. •Current CPR certification. Apply online at: baptist-health.com/jobs]]&gt;&lt;/Description&gt;
       &lt;LookID&gt;arkansas&lt;/LookID&gt;
       &lt;Url&gt;http://jobs.arkansasonline.com/careers/jobsearch/detail/jobId/73451732/viewType/featured&lt;/Url&gt;
    &lt;/item&gt;
      &lt;item&gt;
       &lt;JobID&gt;66703190&lt;/JobID&gt;
       &lt;Title&gt;Telemarketing Agents&lt;/Title&gt;
       &lt;Employer&gt;Arkansas Democrat Gazette         &lt;/Employer&gt;
       &lt;Location&gt;Bryant, AR&lt;/Location&gt;
       &lt;Description&gt;&lt;![CDATA[Telemarketing Agents Needed Position is part-time Starting at $9.00/hour Plus Bonus! Looking for dependable and professional applicants. We are a drug and smoke free company located in Bryant. Hours: Mon-Fri 4:30pm to 8:30pm and Sat. 9am to 6pm. Send resumes to: clewis@wehco.com or P.O. Box 384 Bryant, AR 72089 Arkansas Democrat Gazette Arkansas' Largest NewspaperCLICK THE IMAGE TO VIEW THE AD]]&gt;&lt;/Description&gt;
       &lt;LookID&gt;arkansas&lt;/LookID&gt;
       &lt;Url&gt;http://jobs.arkansasonline.com/careers/jobsearch/detail/jobId/66703190/viewType/featured&lt;/Url&gt;
    &lt;/item&gt;
  &lt;/JobSearchResults&gt;
  sas&lt;/LookID&gt;
           &lt;Url&gt;http://jobs.arkansasonline.com/careers/jobsearch/detail/jobId/73004973/viewType/featured&lt;/Url&gt;
        &lt;/item&gt;
  
  &lt;/JobSearchResults&gt;    
  </code></pre>
  
  <p>I am using the following php code to open the above xml file, and take out the following:
      
          sas
                   <a href="http://jobs.arkansasonline.com/careers/jobsearch/detail/jobId/73004973/viewType/featured" rel="nofollow">http://jobs.arkansasonline.com/careers/jobsearch/detail/jobId/73004973/viewType/featured</a>
        </p>
  
  <pre><code>&lt;/JobSearchResults&gt;    
  </code></pre>
  
  <p>However the php code below:
      
  
  <pre><code>error_reporting(E_ALL | E_STRICT);
  ini_set('display_errors', 1);
  
  // Load File
  // $today = date('Ymd');
  $file = '/Users/jasenburkett/Sites/jobsark/feed' . '.xml';
  $newfile = '/Users/jasenburkett/Sites/jobsark/feed' . '.xml';
  
  $file_contents = file_get_contents($file);
  
  $data = $file_contents;
  
  $parts = explode("&lt;/JobSearchResults&gt;", $data);
  
  // Save File
  file_put_contents($newfile, $data);
  
  ?&gt;
  </code></pre>
  
  <p>This works, however it deletes everything after the first     <code>&lt;/JobSearchResults&gt;</code> and I want to keep the very last one... </p>
  
  <p>Any ideas where i am going wrong?</p>