Question

I have triying to parse some specific elements from a xml feed in my Wordpress using SimplePie and "get_items_tags" to fix namespaces (I wanna print the content, no attributes). At the end nothing is displayed, just empty "p" tags. I have been searching, but no idea of what I can be doing wrong, any help,please? Please check the code:

 <?php if(function_exists('fetch_feed')) {
    include_once(ABSPATH . WPINC . '/feed.php' );
    $feed = fetch_feed( 'http://servizos.meteogalicia.es/rss/predicion/rssLocalidades.action?idZona=32054&dia=0&request_locale=gl');
    $maxitems = $feed->get_item_quantity(25); 
     $rss_items = $feed->get_items(0, $maxitems);}
     if ($maxitems == 0)
    echo  "<p>Nadena</p>";
    else foreach ( $rss_items as $item ) : ?>
        <p><?php echo $item->get_item_tags("http://purl.org/dc/elements/1.1/","tMax"); ?></p>
    <p><?php echo $item->get_item_tags("http://purl.org/dc/elements/1.1/","tMin"); ?></p>


    <?php  endforeach; ?>
Was it helpful?

Solution

I needed to get the content of tag "thumbnail" and this worked for me:

$thumbnail = $item->get_item_tags('', 'thumbnail');
echo $thumbnail[0]["data"];

OTHER TIPS

I finally figure it out! Silly me.... First argument for "get_items_tags" is not xmlns:dc but xmlns. I also had a problem with array data...

<?php $tMin = $item->get_item_tags("Concellos","tMin");
print $tMin[0]["data"];?>

Sorry for my English and any etiquette mistakes. First time around here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top