Processing Method of php Obtaining xml Interface Data
- 2021-10-13 06:52:56
- OfStack
The xml format returns data 1, which is generally like this, but there are also differences:
<?xml version="1.0" encoding="gbk"?>
<root>
<head>
<actdate>20170805</actdate>
<trdate>20170805</trdate>
<trtime>142410</trtime>
<trseq>20170807001</trseq>
<succflag>1</succflag>
<retcode>0000</retcode>
<retmsg> In fact, in fact, the </retmsg>
</head>
<body>
<rowcount>0</rowcount>
</body>
</root>
1 xml directly uses php: simplexml_load_string (); Parse into an array, but when I parse, I prompt that there are data codes that cannot be parsed.
That is, the part of data garbled. I used the statement of header to solve the garbled, but it didn't work. Finally, I used:
iconv('utf-8','gbk',$a);
To solve the problem, transcode first and then analyze
Finally, json conversion will do.