0

I have this problem: I want to generate an xml page from PHP script. The user that want the document can connect to a specific URL with specific parameters. But something not work because I think there are some whitespace chracters between the start of the document and the start of xml declaration:

<?xml version="1.0"?>

I removed in the code all the characters between <?php and header('Content-Type: text/xml; charset=utf-8'); and now look like this:

<?php
header('Content-Type: text/xml; charset=utf-8');

//ini_set('display_errors', 'On');
//error_reporting(E_ALL);

include("some_file.php");
require_once("some_file.php");

// some php code

$xml = new SimpleXMLElement("<response></response>");

// other php code

echo $xml->asXML();
?>

When I run this script, Firefox gives me this message:

XML Parsing Error: XML or text declaration not at start of entity
Line Number 1

Why does I have this error?

Somaye
  • 114
  • 1
  • 3
  • 11
salem
  • 11
  • 3

0 Answers0