Question {code...} How can I get the value of $ out_trade_no?
/*** Return a node value of the string through the node path * $ res_data -- XML format string * return node parameter */function getDataForXML ($ res_data, $ node) {$ xml = simplexml_load_string ($ res_data); $ result = $ xml-> xpath ($ node); while (list (, $ node) = each ($ result )) {return $ node ;}$ _ POST = array ('service' => 'alipay. wap. trade. create. direct ', 'sign' => 'db56d137c71f591abd58b41d5da5f920', 'sec _ id' => 'md5', 'V' => '1. 0', 'Your Y _ data' =>'
1
Recharge
2014123069117121
Default@gmail.com
22:12:32
Trade_status_sync
1
1412302289443
22:12:56
2088211987518229
TRADE_FINISHED
N
0.11
22:12:56
Zfb@gmail.cn
22:12:56
0.11
2088102193791211
8f3d3703e293b95d8de26cbd51d74fe116
N
',); $ Out_trade_no = getDataForXML ($ _ POST ['your Y _ data'],'/your Y/out_trade_no '); var_dump ($ out_trade_no = '000000'); // truevar_dump ($ out_trade_no); // object (SimpleXMLElement) [2]
How can I get the value of $ out_trade_no?
Reply content: Question
/*** Return a node value of the string through the node path * $ res_data -- XML format string * return node parameter */function getDataForXML ($ res_data, $ node) {$ xml = simplexml_load_string ($ res_data); $ result = $ xml-> xpath ($ node); while (list (, $ node) = each ($ result )) {return $ node ;}$ _ POST = array ('service' => 'alipay. wap. trade. create. direct ', 'sign' => 'db56d137c71f591abd58b41d5da5f920', 'sec _ id' => 'md5', 'V' => '1. 0', 'Your Y _ data' =>'
1
Recharge
2014123069117121
Default@gmail.com
22:12:32
Trade_status_sync
1
1412302289443
22:12:56
2088211987518229
TRADE_FINISHED
N
0.11
22:12:56
Zfb@gmail.cn
22:12:56
0.11
2088102193791211
8f3d3703e293b95d8de26cbd51d74fe116
N
',); $ Out_trade_no = getDataForXML ($ _ POST ['your Y _ data'],'/your Y/out_trade_no '); var_dump ($ out_trade_no = '000000'); // truevar_dump ($ out_trade_no); // object (SimpleXMLElement) [2]
How can I get the value of $ out_trade_no?
var_dump( (String)$out_trade_no );
Simplexml parses the simpleElement object and needs to convert the type, as described in the method described by struct.
$doc = new DOMDocument();$doc->loadXML($_POST['notify_data']);$doc->getElementsByTagName( "out_trade_no" )->item(0)->nodeValue;