How to Convert Xml output as String to Key Value pair in PHP -


this question has answer here:

i have output:

<?xml version="1.0" encoding="utf-8"?>   <root>     <disc>svd1679354</disc>     <cut>18349570</cut>     <previewaac>http://api.7digital.com/1.2/track/preview?trackid=18349570&amp;oauth_consumer_key=7dadeprwudk7&amp;country=gb</previewaac>     <previewmp3>http://api.7digital.com/1.2/track/preview?trackid=18349570&amp;oauth_consumer_key=7dadeprwudk7&amp;country=gb</previewmp3>     <downloadlink></downloadlink>     <codec></codec>   </root> 

i want string output read in key value pair can directly read particular key value.

the output stored in string string represents xml.

use simplexml access xml:

$xml = simplexml_load_string($x); // assume xml in $x echo $xml->cut[0]; // access first <cut> node directly 

more on this: http://www.php.net/manual/en/book.simplexml.php
of course, can transform xml array these functions, too


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -