Problem
/** * Returns a node value for a string by node path * $res _data--xml format string * Return node parameter */function getdataforxml ($res _data, $node) {$xml = Simplexml_lo Ad_string ($res _data); $result = $xml->xpath ($node); while (list (, $node) = each ($result)) {return $node; }}$_post = Array (' service ' = ' alipay.wap.trade.create.direct ', ' sign ' = = ' db56d137c71f591abd58b41 d5da5f920 ', ' sec_id ' = ' MD5 ', ' V ' = ' 1.0 ', ' notify_data ' = '
1
recharge
2014123069117121
default@gmail.com
2014-12-30 22:12:32
trade_s
Tatus_sync
1
1412302289443
2014-12-30 22:12:56
2088211987518229
trade_finished
N
0.11
2014-12-30 22:12:56
zfb@gmail.cn
2014-12-30 22:12:56
0.11
2088102193791211
8f3d3703e293b95d8de26cbd51d74fe116
N
', '); $out _trade_no = Getdataforxml ($_post[' notify_data '), '/notify/out_trade_no '); Var_dump ($out _trade_no = = ' 1412302289443 ')); Truevar_dump ($out _trade_no);//object (SimpleXMLElement) [2]
How can I get the value of $out _trade_no
Reply content:
Problem
/** * Returns a node value for a string by node path * $res _data--xml format string * Return node parameter */function getdataforxml ($res _data, $node) {$xml = Simplexml_lo Ad_string ($res _data); $result = $xml->xpath ($node); while (list (, $node) = each ($result)) {return $node; }}$_post = Array (' service ' = ' alipay.wap.trade.create.direct ', ' sign ' = = ' db56d137c71f591abd58b41 d5da5f920 ', ' sec_id ' = ' MD5 ', ' V ' = ' 1.0 ', ' notify_data ' = '
1
recharge
2014123069117121
default@gmail.com
2014-12-30 22:12:32
trade_s
Tatus_sync
1
1412302289443
2014-12-30 22:12:56
2088211987518229
trade_finished
N
0.11
2014-12-30 22:12:56
zfb@gmail.cn
2014-12-30 22:12:56
0.11
2088102193791211
8f3d3703e293b95d8de26cbd51d74fe116
N
', '); $out _trade_no = Getdataforxml ($_post[' notify_data '), '/notify/out_trade_no '); Var_dump ($out _trade_no = = ' 1412302289443 ')); Truevar_dump ($out _trade_no);//object (SimpleXMLElement) [2]
How can I get the value of $out _trade_no
SimpleXML Parse is the Simpleelement object, need type conversion, such as the way the son said the method can be
$doc = new DOMDocument();$doc->loadXML($_POST['notify_data']);$doc->getElementsByTagName( "out_trade_no" )->item(0)->nodeValue;