PHP namespace simplexml problems

Usually, people use children().

$rss = simplexml_load_string(
    '<?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0" xmlns:moshtix="http://www.moshtix.com.au">
        <channel>
            <link>qweqwe</link>
            <moshtix:genre>asdasd</moshtix:genre>
        </channel>
    </rss>'
);

foreach ($rss->channel as $channel)
{
    echo 'link: ', $channel->link, "\n";
    echo 'genre: ', $channel->children('moshtix', true)->genre, "\n";
}

Leave a Comment