I'd like to get all used tags (in $feed->channel->item) from the rss feed without knowing the actual tag name. Yes, maybe this sounds weird, let me explain.
Example
<item>
<title>Inademen van bloem kan astma veroorzaken</title>
<link>http://www.nu.nl/gezondheid/3872032/inademen-van-bloem-kan-astma-veroorzaken.html</link>
<description>Het keer op keer inademen van het fijne stof dat afkomstig is van het bakmeel bloem, kan astma veroorzaken. </description>
</item>
<item>
<title>Inademen van bloem kan astma veroorzaken</title>
<link>http://www.nu.nl/gezondheid/3872032/inademen-van-bloem-kan-astma-veroorzaken.html</link>
<description>Het keer op keer inademen van het fijne stof dat afkomstig is van het bakmeel bloem, kan astma veroorzaken. </description>
<test>Testing!</pubDate>
</item>
What I would like to achieve (sample script output for the above XML):
- Tag
<title>
used 2 times - Tag
<link>
used 2 times - Tag
<description>
used 2 times - Tag
<test>
used 1 times
How can I do this? I could coun't all tags easily when I already know the tag name, but how to count them without knowing what tags are being used within <item>
?
At the moment my script simply loads the feed and loop through/display the items:
<?php
getFeed('http://www.nu.nl/feeds/rss/gezondheid.rss');
function getFeed($feedUrl) {
$feedUrl = file_get_contents($feedUrl);
$feedXml = new SimpleXmlElement($feedUrl);
$itemTags = array();
echo "<ul>";
foreach($feedXml->channel->item as $item) {
echo "<li><a href='$item->link'>" . $item->title . "</a></li>";
}
echo "</ul>";
}