javascript - Read xml content using php or jquery

WBOY
Release: 2016-07-06 13:51:14
Original
834 people have browsed it

Now there is such a demand, as shown in the picture

javascript - Read xml content using php or jquery

This is the information I returned through the form post order number and key to a logistics company interface. How can I use php or jquery to read the above time, status and other information, and then display it on another html page? ? urgent! ! !

Reply content:

Now there is such a demand, as shown in the picture

javascript - Read xml content using php or jquery

This is the information I returned through the form post order number and key to a logistics company interface. How can I use php or jquery to read the above time, status and other information, and then display it on another html page? ? urgent! ! !

http://www.runoob.com/php/func-simplexml-load-string.html
http://www.w3school.com.cn/jquery/ajax_ajax.asp

---Update---
If you cannot submit it to the logistics website directly using ajax (jsonp is almost never supported, so it is impossible to submit it.)

Use the form to submit it to your own PHP program. The PHP program constructs the request content, curls the request to the logistics website, receives the returned XML, and parses it.

Or if the interface of the logistics website supports asynchronous return of results, it is also possible.

You want to ask how to send HTTP request using PHP

<code>function send_post($url, $post_data) {  
  
  $postdata = http_build_query($post_data);  
  $options = array(  
    'http' => array(  
      'method' => 'POST',  
      'header' => 'Content-type:application/x-www-form-urlencoded',  
      'content' => $postdata,  
      'timeout' => 15 * 60 // 超时时间(单位:s)  
    )  
  );  
  $context = stream_context_create($options);  
  $result = file_get_contents($url, false, $context);  
  
  return $result;  
}</code>
Copy after login

The above return value is the above xml content. If I don’t know the specific interface, I can’t write an example.

Forget about jQuery, it is a cross-domain interface and does not support jsonp

It is recommended to use PHP for processing: PHP processing XML

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template