I am trying to parse https://www.joc.com/rssfeed. There are a couple of things I cannot seem to access. For example, how would I access (1) <dc:creator>Keith Wallis, Special Correspondent | Jul 30, 2021 3:16PM EDT </dc:creator> and also [caption caption= ][/caption]? I cannot seem to figure out how to access. So far I have the below code:
I have the following code:
function display_rss_card(){
ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20100101 Firefox/9.0');
$rss = simplexml_load_file('https://www.joc.com/rssfeed');
$i = 0;
foreach ($rss->channel->item as $item) {
if($i<9){
$x = $item->description->children();
echo '<div class="card" style="width: 18rem;">';
echo ' <img class="card-img-top" src="'.$x->img['src'].'" alt="Girl in a jacket" alt="Card image cap">';
echo ' <figcaption class="figure-caption text-center">A caption for the above image.</figcaption>';
echo ' <div class="card-body">';
echo ' <h5 class="card-title">'.$item->title.'</h5>';
echo ' <p class="card-text">
Published: '.$item->pubDate.' / '.$item->description.'
</p>';
echo ' <a href="'.$item->link.'">Read More...</a>';
echo ' </div>';
echo '</div>';
echo '<br/>';
}
$i++;
}
}