国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) PHP submits XML via POST, obtains XML, and parses XML details and examples

PHP submits XML via POST, obtains XML, and parses XML details and examples

Jan 06, 2017 pm 03:12 PM

PHP Submit XML in POST mode, obtain XML, and finally parse XML

Submit XML in POST mode

// Do a POST
$data="<?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39;?>
<TypeRsp>
<CONNECT_ID>1</CONNECT_ID>
<MO_MESSAGE_ID>2</MO_MESSAGE_ID>
</TypeRsp>";
 
//$data = array(&#39;name&#39; => &#39;Dennis&#39;, &#39;surname&#39; => &#39;Pallett&#39;);
 
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,"http://localhost/handle_form.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// grab URL, and print
curl_exec($ch);

Get POST to XML, and parse it

handle_form.php

$file_in = file_get_contents("php://input"); //接收post數(shù)據(jù)
 
$xml = simplexml_load_string($file_in);//轉(zhuǎn)換post數(shù)據(jù)為simplexml對象
 
foreach($xml->children() as $child)  //遍歷所有節(jié)點數(shù)據(jù)
{
 
echo $child->getName() . ": " . $child . "<br />"; //打印節(jié)點名稱和節(jié)點值
 
//if($child->getName()=="from")  //撿取要操作的節(jié)點
//{
//echo "i say ". ": get you!" . "<br />"; //操作節(jié)點數(shù)據(jù)
//}
}
 
exit;

Thank you for reading, I hope it can help everyone, thank you for your support of this site!

For more PHP articles about submitting XML via POST, obtaining XML, parsing XML details and examples, please pay attention to the PHP Chinese website!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)