title: Are Blank Tag Names Causing A Parsing Error?
body: <p>I'm trying to restructure some XML by taking the data, creating a DOM doc, and transferring across just the bits I need, before saving the output, however I keep getting a "XML Parsing Error: no element found: Line Number 1, Column 1:" error. I think it's related to the blank tags inside the first :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;report title="My Programs" name="aAffiliateMyProgramsReport" time="2012-11-27 16:06"&gt;
  &lt;matrix rowcount="2"&gt;
  &lt;rows&gt;
   &lt;row&gt;
    &lt;&gt;You must select one or more sale events before editing&lt;/&gt;
   &lt;/row&gt;
  &lt;/rows&gt;
  &lt;/matrix&gt;
  &lt;matrix rowcount="2343"&gt;
      &lt;rows&gt;
          &lt;row&gt;
              &lt;siteName&gt;thewebsite.com&lt;/siteName&gt;
              &lt;affiliateId&gt;123456&lt;/affiliateId&gt;
              &lt;programName&gt;TheProgram.com&lt;/programName&gt;
              &lt;currentStatusExcel&gt;Ok&lt;/currentStatusExcel&gt;
              &lt;programId&gt;203866&lt;/programId&gt;
              &lt;applicationDate&gt;2012-09-15&lt;/applicationDate&gt;
              &lt;programTariffAmount&gt;0.0&lt;/programTariffAmount&gt;
              &lt;programTariffCurrency&gt;GBP&lt;/programTariffCurrency&gt;
              &lt;programTariffPercentage&gt;0.0&lt;/programTariffPercentage&gt;
              &lt;status&gt;Accepted&lt;/status&gt;
              &lt;event&gt;Unique visitor&lt;/event&gt;
              &lt;eventIdView&gt;2&lt;/eventIdView&gt;
              &lt;eventLastModified&gt;2011-03-15&lt;/eventLastModified&gt;
              &lt;segmentID&gt;1&lt;/segmentID&gt;
              &lt;segmentName&gt;General&lt;/segmentName&gt;
              &lt;lastModified&gt;2012-09-15&lt;/lastModified&gt;
          &lt;/row&gt;........
  </code></pre>
  
  <p>And here's the PHP I'm trying to run:</p>
  
  <pre><code>//contents of MyPrograms report - tested $query in browser many times: it is correct
  $query = $q1.$siteID.$q2.$rKey.$q3;
  
  //create DOM document for newTree
  $newTree = new DOMDocument();
  $newTree-&gt;formatOutput =true;
  $r = $newTree-&gt;createElement ("ProgramTariffs");
  $newTree-&gt;appendChild($r);
  
  //load contents of MyPrograms report into an xml element
  //$oldTree = simplexml_load_file($query);
  //that wasn't working so tried file_get_contents instead
  $oldTree = file_get_contents($query);
  
  //the above is now at least allowing this script to produce an xml file, but it just contains 
  "&lt;?xml version="1.0"?&gt; &lt;ProgramTariffs/&gt;" 
  //and still throws the no element found error.................................
  
  //for each instance of a program id in $oldTree.....
  foreach($oldTree-&gt;matrix-&gt;rows-&gt;row as $program)
      { //an attempt to skip over first $program if nothing is set
      if (!empty($program-&gt;programId)) {
  
  //create the top line container tag
          $row = $newTree-&gt;createElement ("programTariff");
  
  //create the container tag for programId
          $progID = $newTree-&gt;createElement("programId");
          //fill it with the information you want
          $progID-&gt;appendChild ( $newTree-&gt;createTextNode ( $program-&gt;programId ) );
          //attach this information to the row
          $row-&gt;appendChild($progID);
  
  //create the container tag for eventName
          $eventName = $newTree-&gt;createElement("eventName");
          //fill it with the information you want
          $eventName-&gt;appendChild ( $newTree-&gt;createTextNode ( $program-&gt;event ) );
          //attach this information to the row
          $row-&gt;appendChild($eventName);
  
  //create the container tag for eventAmount
          $eventPercent = $newTree-&gt;createElement("eventPercent");
          //fill it with the information you want
          $eventPercent-&gt;appendChild ( $newTree-&gt;createTextNode ( $program-&gt;programTariffPercentage ) );
      //attach this information to the row
          $row-&gt;appendChild($eventPercent);
  
    //attach all of the above to a row in NewTree
      $r-&gt;appendChild ($row);
       }
  }
  //save the output
  $newTree-&gt;save("ProgramTariffs.xml");
  </code></pre>
  
  <p>Have I made a basic mistake in accessing the original XML, or do I need to find a better way to work around the row containing a tag name of "&lt;>" ?</p>
  
  <p>I await your wrath / salvation</p>