phpxmlentityreference

I am getting " EntityRef: expecting ';' error while creating xml through php "


This is my XML,I am using php code for creating this xml. Please see screenshot for code:enter image description here

<?xml version="1.0"?>
<LoggedErrors>
  <LoggedError>
  <DateTime>2018-03-30T10:28:28+00:00</DateTime>
  <Errors/>
  <Request>
    <FlightGroup>
      <ArrivalTime>
        <Hour>12</Hour>
        <Millisecond>0</Millisecond>
        <Minutes>20</Minutes>
        <Seconds>0</Seconds>
        <Day>12</Day>
        <DayOfWeek>Thursday</DayOfWeek>
        <Month>4</Month>
        <Year>2018</Year>
      </ArrivalTime>
    </FlightGroup>
   </Request>
 </LoggedError>
</LoggedErrors>

Solution

  • public  function printResult($raw_data){
        // adding Content Type
        header("Content-type: text/xml");
        // Converts PHP Array to XML with the root element being 'root-element-here'
        $xml = Excellence_Envision_Helper_Errorflile::createXML('LoggedError', $raw_data);
    
        return $xml->saveXML();
    
        }
    

    Try to remove this code from your function and I think it will work fine then.

    header("Content-type: text/xml");