CodeIgniter Forums
Reading XML streams - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Reading XML streams (/showthread.php?tid=15676)



Reading XML streams - El Forum - 02-11-2009

[eluser]Dahak-II[/eluser]
This is more a general PHP programming issue, most likely...

I'm re-writing a project that originally was processed as an ASP page.

I need to get an XML stream into a variable. Seems simple enough sounding.

My original local test setup had one script use CURL to post XML data to my CI controller. The target in the form of 'https://thissite.com/index.php/targetcontrollername'

In the controller, I could read the posted XML with:

Code:
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents("php://input"); // ensure the variable exists

Even though the PHP 5 ini is configured to populate $HTTP_RAW_POST_DATA, it winds up being unset.

For my simpler purely local tests, the file_get_contents() call gets me my XML data, but is that the proper way to do so?

When I tried to use the CI controller as a target for the existing remote site's test environment, I get no XML to my controller.

What would be the most straightforward way to read an XML stream in a CI controller call?


Reading XML streams - El Forum - 02-11-2009

[eluser]TheFuzzy0ne[/eluser]
I have no suggestions, sorry. I think it's time to start pulling the code to pieces and adding some echoes for debugging.


Reading XML streams - El Forum - 02-11-2009

[eluser]prezet[/eluser]
How about using PHP's simplexml.

http://uk.php.net/simplexml

Load the file like so:

http://uk.php.net/manual/en/function.simplexml-load-file.php


Reading XML streams - El Forum - 02-11-2009

[eluser]Dahak-II[/eluser]
[quote author="prezet" date="1234407798"]How about using PHP's simplexml.

http://uk.php.net/simplexml

Load the file like so:

http://uk.php.net/manual/en/function.simplexml-load-file.php[/quote]

I have no problems parsing the test streams I've posted (so far, at least).

What I am trying to determine is how to reliably read the XML stream from the page load, I am not trying to load the XML from a file.


Reading XML streams - El Forum - 03-25-2009

[eluser]Nabeel[/eluser]
I'm having trouble with this as well, did you find a resolution?