PHP how to parse the WEBSERVICE interface returned data WEBSERVICE server, they wrote an interface http://XXX.XXX.XXX.XX/Info.asmx with. net? Wsdl
I used PHP to call this interface.
Try {$ wsdl = "http://XXX.XXX.XXX.XX/Info.asmx? Wsdl "; $ client = new SoapClient ($ wsdl); $ param = array ('strname' => 'Wu Xiaoming ', 'stridcard' => '4528xxxxxxxx ', 'descipare' => '123'); $ res = $ client-> GetBasicInfo ($ param); print_r ($ res);} catch (SOAPFault $ e) {var_dump ($ e );}
The following result is displayed:
StdClass Object ([GetBasicInfoResult] => stdClass Object ([any] =>
4507 ............
4507 ............
Wu ......
Male
4528 ............
1966-03-10T00: 00: 00 + 08: 00
Road ............
2011-05-23T00: 00: 00 + 08: 00
2011-05-23T00: 00: 00 + 08: 00
2017-05-22T00: 00: 00 + 08: 00
Qinzhou ............
AAA
C1 certificate
))
[Any] => It is not like a standard XML. How can I use PHP to obtain these values?
Reply to discussion (solution)
The data you provided lacks the root node. add it by yourself.
The data is divided into two parts: the first part is the data type declaration, and the second part is the data
What we care about is the second part.
Use SimpleXMLElement to obtain
SimpleXMLElement Object ([DocumentElement] => SimpleXMLElement Object ([Employee] => SimpleXMLElement Object ([ID_ECERT] => 4507 ............ [ECERTID] => 4507 ............ [NAME] => Wu ...... [SEX] => male [IDCARD] => 4528 ............ [BIRTHDAY] => 1966-03-10T00: 00: 00 + 08: 00 [ECERTAREA] => Road ............ [FIRSTDATE] => 2011-05-23T00: 00: 00 + 08: 00 [BEGINDATE] => 2011-05-23T00: 00: 00 + 08: 00 [ENDDATE] => 2017-05-22T00: 00: 00 + 08: 00 [GRANTORGAN] => Qinzhou ............ [CREDITLEVEL] => AAA [DRVLICENSE] => C1 certificate )))
The data you provided lacks the root node. add it by yourself.
The data is divided into two parts: the first part is the data type declaration, and the second part is the data
What we care about is the second part.
Use SimpleXMLElement to obtain
SimpleXMLElement Object ([DocumentElement] => SimpleXMLElement Object ([Employee] => SimpleXMLElement Object ([ID_ECERT] => 4507 ............ [ECERTID] => 4507 ............ [NAME] => Wu ...... [SEX] => male [IDCARD] => 4528 ............ [BIRTHDAY] => 1966-03-10T00: 00: 00 + 08: 00 [ECERTAREA] => Road ............ [FIRSTDATE] => 2011-05-23T00: 00: 00 + 08: 00 [BEGINDATE] => 2011-05-23T00: 00: 00 + 08: 00 [ENDDATE] => 2017-05-22T00: 00: 00 + 08: 00 [GRANTORGAN] => Qinzhou ............ [CREDITLEVEL] => AAA [DRVLICENSE] => C1 certificate )))
No.
The data you provided lacks the root node. add it by yourself.
The data is divided into two parts: the first part is the data type declaration, and the second part is the data
What we care about is the second part.
Use SimpleXMLElement to obtain
SimpleXMLElement Object ([DocumentElement] => SimpleXMLElement Object ([Employee] => SimpleXMLElement Object ([ID_ECERT] => 4507 ............ [ECERTID] => 4507 ............ [NAME] => Wu ...... [SEX] => male [IDCARD] => 4528 ............ [BIRTHDAY] => 1966-03-10T00: 00: 00 + 08: 00 [ECERTAREA] => Road ............ [FIRSTDATE] => 2011-05-23T00: 00: 00 + 08: 00 [GRANTORGAN] => Qinzhou ............ )))
Moderator. can you give an example?
Extract with regular expression
$s = preg_replace('/.+(
GetBasicInfoResult->any);$xml = simplexml_load_string($s);print_r($xml);
The result of my example is displayed.
I thought I could get the data directly. I still needed to operate on the string. forget it. close the token.