I have researched this but have had trouble implementing it into my code. I have:
<?php
$rss = new DOMDocument();
$rss->load('FEEDURL');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
//author
'author' => $node->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/','dc') >item(0)->nodeValue
);
array_push($feed, $item);
}
?>
the section with the comment //author
is where I am having problems. The tag in the RSS Feed is <dc:author>
If you have a relevant article that I have missed, please send me there and don't vote down. Thanks :)
dc
is namespace, author
is a tag name, so if http://purl.org/dc/elements/1.1/
is namespaceURI for dc
you need to search like this:
$node->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/','author')