What controls or functions can be used to initiate XML requests and retrieve data on PHP?-php Tutorial

Source: Internet
Author: User
Ask what controls or functions on PHP can initiate XML requests and get back data. now we need to use PHP to make a flight query and order a program. We contacted a business travel platform, the documents provided by their technology are a submission form. after they are submitted to their server, an XML data is returned, if you want to use PHP controls or functions to initiate XML requests and retrieve data, you will be confused. It is better to have some cases. ------ Solution -------------------- P: determine which controls or functions on PHP can initiate XML requests and obtain the returned data.
Now I want to use PHP for a flight query and ordering procedure. I contacted a business travel platform,
The documentation provided by their technology is a submission form. after it is submitted to their server, an XML data is returned, asking me to use PHP controls or functions to initiate XML requests and retrieve the data back.

I'm confused. please try again. thank you. It is better to have some cases.

------ Solution --------------------
PHP code
  Xmldata'; // The xml $ url to be sent = 'http: // localhost/test/getXML. php '; // receive XML address $ header = 'content-type: text/XML'; // Define Content-type as xml $ ch = curl_init (); // initialize curlcurl_setopt ($ ch, CURLOPT_URL, $ url); // Set the link curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // Set whether to return information curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // Set the HTTP header curl_setopt ($ ch, CURLOPT_POST, 1); // Set it to the POST method curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ xml ); // POST data $ response = Curl_exec ($ ch); // receives the returned information if (curl_errno ($ ch) {// error message print curl_error ($ ch );} curl_close ($ ch); // Close the curl link echo $ response; // display the returned information?>
------ Solution --------------------
Like the upstairs curl, snoopy, fopen, or fsockopen...

Xml can be obtained

Xml parsing
SimpleXML

Read through the usage of these things first, and then you can start the work, very simple things

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.