How to read a tag with two attributes



I have an xml rss with a special tag I do not know how to read the second part, in this case the subcategory


XML RSS:



<?xml version="1.0" encoding="UTF-8"?>

<channel>
<category text="Category">
<category text="Subcategory"/>
</category>
</channel>

</rss>


PHP



//this gives the category
$category = $feed->channel->category->attributes();
echo $category . '<br>';

//I tried this but only gives category and I need subcategory too
foreach ($feed->channel->category->attributes() as $item) {
echo $item . '<br>';
}

No comments:

Post a Comment