Re: Reading an XML outputting PHP file as XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:
IG wrote:
Hi.
I have a PHP file that outputs as XML from a database. i have used the header() function to output the correct header but when I use the simplexml function it is trying to parse the php file itself and not the output of the php file. I can't get my head round this. Can anyone help me?

your running the simplexml function on the php file and not its output.




You are doing (something like) this:

$xml = simplexml_load_string(file_get_contents("/www/html/foo.php");

You need to do something like this:

$xml = simplexml_load_string(file_get_contents("http://ba.com/foo.php";);

Alternatively, if you don't want the PHP script to be visible on the web server, make it executable (with a shebang) and then execute it and pass the output to simplexml_load_string(). You know, using shell_exec() or the backticks operator.

Note that simplexml_load_string() doesn't care about what type of file you reported it as (with Content-Type or something). It only cares that the string you pass it is XML. So if your script is the ONLY one that will ever get this XML, you don't need to bother with the content type.

Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux