Jump to content

Recommended Posts

Ok so this is the xml I'm trying to read basically goes:

 

<tumblr>
            <posts>
                       <post url="http://stuff">
                                other stuff
                       </post>
                       <post url="http://stuff">
                                other stuff
                       </post>
                       <post url="http://stuff">
                                other stuff
                       </post>
              </posts>
</tumblr>

 

If it helps to actually see it: http://candybrie.tumblr.com/api/read?type=post&start=0&num=4&type=text

 

My problem is getting the url's from each post.

 

The relevant php looks like this:

 

foreach ($xml->posts->post AS $post) 
{
$title = $post->{'regular-title'};
$post = $post->{'regular-body'};
$link = $post->attributes()->url;
$small_post = substr($post,0,320);

echo '<h1>'.$title.'</h1>';
echo '<p>'.$small_post;
echo "?";
echo '<a target=frame2 href="'.$link.'">Read More</a></p>';
}

 

The problem is with getting the url attribute, it gives me nothing. If I do this

 

$link = $xml->posts->post->attributes()->url;

 

I can get the first post's.

 

This is the first thing I've actually done in php so sorry if there is a really obvious answer or flaw.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.