3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * How to get attribute of node with namespace using SimpleXML? * * @link http://stackoverflow.com/q/6576773/367456 */ $buffer = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <entry> <yt:duration seconds="1870" yt:seconds="0 in yt namespace" /> </entry> </feed>'; $xml = new SimpleXMLElement($buffer); if (!defined('LIBXML_DOTTED_VERSION')) { echo "PHP/LIBXML unsupported/too old."; return; } echo "ibxml version: ", LIBXML_DOTTED_VERSION, "\n"; $youtube = $xml; echo 'via attributes(): ', $youtube->entry->children('yt', TRUE)->duration->attributes()->seconds, "\n"; echo 'via array-access: ', $youtube->entry->children('yt', TRUE)->duration['seconds'], "\n"; echo 'via property : ', $youtube->entry->children('yt', TRUE)->duration->seconds, "\n";

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
164.63 ms | 3074 KiB | 10 Q