SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Target entry in RSS

    I have 2 images elements in an RSS and i'm struggling to target them.



    Code:
    <?xml version="1.0"  encoding="UTF-8"?>
    <rss version="2.0">
    <channel>
        <title>RSS title</title>
        <link>http://www.yoursite.com</link>
        <description>description goes here</description>
        <item>
            <title>Title of post</title>
            <ContentItem Href="http://feeds.yoursite.com/imgjpg0876a797099de1d7389127472a413e3aad741551.jpg">
                  <MediaType FormalName="Pictureport" />
                  <MimeType FormalName="image/jpg" />
                  <Property FormalName="caption" value="Image caption" />
           </ContentItem>
            <ContentItem Href="http://feeds.yoursite.com/imgjpg0876a797099de1d7389127472a413e3aad741551.jpg">
                  <MediaType FormalName="Pictureport" />
                  <MimeType FormalName="image/jpg" />
                  <Property FormalName="caption" value="Image caption" />
           </ContentItem>
        </item>
    </channel>
    </rss>
    If i want to grab the title it's simply

    PHP Code:
    $RSS_DOC simpleXML_load_file($feed_url);
    $rss_title $RSS_DOC->channel->item->title;
    echo 
    $rss_title 
    but how do i grab the image url? tried a couple of combinations but can't put my finger on it. I need to grab both images into separate variables.

  2. #2
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind i've managed it

    $RSS_DOC->channel->item->ContentItem[0]->attributes()->Href;
    $RSS_DOC->channel->item->ContentItem[1]->attributes()->Href;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •