How to Convert Xml output as String to Key Value pair in PHP -
this question has answer here:
- how parse , process html/xml in php? 27 answers
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&oauth_consumer_key=7dadeprwudk7&country=gb</previewaac> <previewmp3>http://api.7digital.com/1.2/track/preview?trackid=18349570&oauth_consumer_key=7dadeprwudk7&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
Post a Comment