Amit Dhamu

Software Engineer


Learn how to use SimpleXML to parse XML documents using PHP.

<?xml version="1.0" encoding="UTF-8"?>
        <album><![CDATA[Mylo Xyloto]]></album>
$xml_file = file_get_contents('songs.xml');
$xml = new SimpleXMLElement($xml_file);
$songs = $xml->song;

foreach ($songs as $song) {
    echo $song->artist // returns Coldplay
    echo $song->title // returns Paradise
    echo $song->album // returns Mylo Xyloto

 simplexml / xml / php / rss

Encode & Decode JSONError Document

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.