3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="utf-8"?> <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"> <channel> <title>werwer</title> <link>werwerwe</link> <item> <g:id>704667</g:id> <title>Nike</title> <description>erterterter</description> </item> <item> <g:id>4456456</g:id> <title>Nike</title> <description>erterterter</description> </item> </channel></rss>'; $xml = simplexml_load_string($xml); $ns = $xml->getNamespaces(true); foreach ($xml->channel->item as $item) { echo $item->children($ns['g'])->id.PHP_EOL; }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
704667 4456456

preferences:
168.51 ms | 407 KiB | 5 Q