views:

17

answers:

1

Hay, i'm trying to parse an RSS feed from a wordpress blog. So far everything is working as expected, here's my code

<?php
    $feedUrl = "FEED URL"; 
    $rawFeed = file_get_contents($feedUrl); 
    $xml = new SimpleXmlElement($rawFeed);
    $channel = $xml->channel;
    $items = $channel->item;
    foreach($items as $item){
        echo "<a href='".$item->link."'>".$item->title."</a>";
        echo $item->description;
        echo $item->pubDate;

    }       

?>

However, i seem to be having issues getting the Author of the post. The data has got to be somewhere because when Safari renders the feed the author appears.

Here is my RSS feed

SimpleXMLElement Object
(
[@attributes] => Array
    (
        [version] => 2.0
    )

[channel] => SimpleXMLElement Object
    (
        [title] => My Blog title
        [link] => http://blog.com/new/blog
        [description] => Just another WordPress site
        [lastBuildDate] => Thu, 22 Jul 2010 08:02:19 +0000
        [language] => en
        [generator] => http://wordpress.org/?v=3.0
        [item] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [title] => Second post
                        [link] => http://blog.com/new/blog/?p=5
                        [comments] => http://blog.com/new/blog/?p=5#comments
                        [pubDate] => Thu, 22 Jul 2010 08:02:19 +0000
                        [category] => SimpleXMLElement Object
                            (
                            )

                        [guid] => http://blog.com/new/blog/?p=5
                        [description] => SimpleXMLElement Object
                            (
                            )

                    )

                [1] => SimpleXMLElement Object
                    (
                        [title] => Hello world!
                        [link] => http://blogl.com/new/blog/?p=1
                        [comments] => http://blog.com/new/blog/?p=1#comments
                        [pubDate] => Thu, 22 Jul 2010 07:22:40 +0000
                        [category] => SimpleXMLElement Object
                            (
                            )

                        [guid] => http://blog.com/new/blog/?p=1
                        [description] => SimpleXMLElement Object
                            (
                            )

                    )

            )

    )

)

any help would be awesome!

Thanks

+1  A: 

In a Wordpress RSS feed, the author info is in the <dc:creator> tag. Check out whether that applies to your feed as well.

The XML parser swallows the tag because of the colon in the tag name.

See this question for how to get those tags to display as well.

Pekka
Thank you, the link in this answer explained how to go about getting the Author (creator).
dotty