How PHP takes data from XML
' Http://box.zhangmen.baidu.com/x?op=12&count=1&title= in the winter $$ Qi Qin $ $ '
This interface provides XML-formatted files, which I use $xml = file_get_contents (' http://box.zhangmen.baidu.com/x?op=12&count=1&title= about in winter $$ Qi Qin $ $ '); How to get the value inside the XML, ask PHP God to write some of the code for my reference, thank you very much.
$xml = file_get_contents (' http://box.zhangmen.baidu.com/x?op=12&count=1&title= in the winter $$ Qi Qin $ $ ');
$result = simplexml_load_string ($xml);
Print results
Object (SimpleXMLElement) [1]
Public ' count ' = String ' 1 ' (length=1)
Public ' url ' = =
Object (SimpleXMLElement) [2]
Public ' encode ' =
Object (SimpleXMLElement) [5]
Public ' decode ' =
Object (SimpleXMLElement) [6]
Public ' type ' = = String ' 8 ' (length=1)
Public ' lrcid ' = String ' 14706 ' (length=5)
Public ' flag ' = = String ' 1 ' (length=1)
Public ' durl ' =
Object (SimpleXMLElement) [3]
Public ' encode ' =
Object (SimpleXMLElement) [7]
Public ' decode ' =
Object (SimpleXMLElement) [8]
Public ' type ' = = String ' 8 ' (length=1)
Public ' lrcid ' = String ' 14706 ' (length=5)
Public ' flag ' = = String ' 1 ' (length=1)
Public ' peer ' =
Object (SimpleXMLElement) [4]
Public ' hash ' = String ' d1cae9f7634c5aa3d54d7b1b1ad4c5b79b6e97ff ' (length=40)
Public ' url ' = =
Object (SimpleXMLElement) [9]
Public ' type ' = = String ' mp3 ' (length=3)
Public ' size ' = = String ' 5710896 ' (length=7)
Public ' bitrate ' = String ' 192 ' (length=3)
I want to take
<br />http://zhangmenshiting.baidu.com/data2/music/64380827/ Z2zmbgvuaw9fn6nndk6ap5wxcghomgieazszagpvmgxly2tnz5ebawnpamaaazlrk2lqmzaxa3ctzjezmw1ncgvll1qin5t1ywbkbgvpb2tizgxqz2draje $<br>
<br />64380827.mp3?xcode=43b1f8bf459a441832ad12772e3b3b77eaa48b2ded70843d&mid=0.18038312962142<br>
Encode the data inside. What should I do, the value of that object (SimpleXMLElement) [5] is taken out.
------Solution--------------------
$xml = file_get_contents (' http://box.zhangmen.baidu.com/x?op=12&count=1&title= in the winter $$ Qi Qin $ $ ');
$result = simplexml_load_string ($xml, ' simplexmlelement ', libxml_nocdata);
Var_dump ($result->url->decode);
------Solution--------------------
$xml = file_get_contents (' http://box.zhangmen.baidu.com/x?op=12&count=1&title= in the winter $$ Qi Qin $ $ ');
$result = simplexml_load_string ($xml, ' simplexmlelement ', libxml_nocdata);
$ret = (array) $result->url;
echo $ret [' encode ']. "
";
echo $ret [' decode '];
http://zhangmenshiting.baidu.com/data2/music/64380827/ Z2zmbgvuaw9fn6nndk6ap5wxcjztb5lsamrjaw2znjmtawxrawmycwdoa2drz26zazhlmzaxa3ctzjezmw1ncgvll1qin5t1ywbmbwlvchflzmxqawttbde $
64380827.mp3?xcode=b89b492058ceab79743a96683617a8f2eaa48b2ded70843d&mid=0.39499944964564
------Solution--------------------
XML = file_get_contents (' http://box.zhangmen.baidu.com/x?op=12&count=1&title= about in winter $$ Qi Qin $ $ ');
$result = simplexml_load_string ($xml);
Echo strval ($result->url->encode);
Echo strval ($result->url->decode);
http://zhangmenshiting.baidu.com/data2/music/64380827/ Z2zmbgvuaw9fn6nndk6ap5wxcgvpzpuazjdrbgtqmm1my2lolppnmpsxzwzubzyclmlmmzaxa3ctzjezmw1ncgvll1qin5t1ywbmbgxsamxlagvrbg9tate $
64380827.mp3?xcode=140db3e8864c55164ad0bce2297ede73eaa48b2ded70843d&mid=0.38763446277961