views:

23

answers:

1

I have just started a project that involves me sending data using POST in HTML forms to a another companies server. This returns XML. I need to process this XML to display certain information on a web page.

I am using PHP and have no idea where to start with how to access the XML. Once I knwo how to get at it I know how to access it using XPath.

Any tips of how to get started or links to sites with information on this would be very useful.

A: 

You should check out the DOMDocument() class, it comes as part of the standard PHP installation on most systems.

http://us3.php.net/manual/en/class.domdocument.php

ohhh, I see. You should set up a PHP script that the user form posts to. If you want to process the XML response you should then pass those fields on to the remote server using cURL.

http://us.php.net/manual/en/book.curl.php

A simple example would be something like:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://the_remote_server");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$YourXMLResponse = curl_exec($ch);
?>
akellehe
Thanks, I understand how to set up the parser using DOMDocument() or SimpleXML, but when I post the data how do I get the XML that is returned to put into the DOMDocument or simpleXML.
Use cURL, I edited the answer to explain it above.
akellehe
Thats great, exactly what I was after. Thanks