I have an API consisting of two files that takes a url from a user, processed it, and sends an array to another file to return XML data back to the user. My problem is that I do not know how to get the return data (if I were the user) and parse it. Using a browser, the XML will display fine. I am hoping there are PHP functions that will send the url and retrieve the result for parsing.
Here is an example of the url sent by the user:
Those query vars are then processed, sent to another server, and an array of results is returned. I then create a query string from those results place that string into another query and send that to another file that returns the XML.
The query string looks like this:
XMLProcess.php?Q=Element1^Value|Element2^Value|ElementThree^Value ... etc.
That file looks like this
$dom = new DOMDocument("1.0", 'utf-8');
$QArray = explode('|',$_REQUEST[Q]);
foreach($QArray as $value)
$x = explode('^',$value);
$XMLItems[$x] = $x;
$root = $dom->createElement("Requests");
foreach($XMLItems as $key => $value)
$key = $dom->createElement($key);
$variable = $dom->createTextNode($value);
As I say, this will display well-formatted xml in a browser, but is there a way to receive and parse this xml data with PHP?
Am I creating extra problems by having a secondary processing file (XMLProcess.php), rather than just including this XML creation code in the xmlapi.php file?
I'm trying to avoid using something like CURL or SOAP, if possible.