PHP SimpleXML Breaking when trying to traverse nodes

payasito40

New Member
I'm trying to read the xml information that tumblr provides to create a kind of news feed off the tumblr, but I'm very stuck.\[code\]<?php $request_url = 'http://candybrie.tumblr.com/api/read?type=post&start=0&num=5&type=text'; $xml = simplexml_load_file($request_url); if (!$xml) { exit('Failed to retrieve data.'); } else { foreach ($xml->posts[0] AS $post) { $title = $post->{'regular-title'}; $post = $post->{'regular-body'}; $small_post = substr($post,0,320); echo .$title.; echo '<p>'.$small_post.'</p>'; } }?>\[/code\]Which always breaks as soon as it tries to go through the nodes. So basically "tumblr->posts;....ect" is displayed on my html page.I've tried saving the information as a local xml file. I've tried using different ways to create the simplexml object, like loading it as a string (probably a silly idea). I double checked that my webhosting was running PHP5. So basically, I'm stuck on why this wouldn't be working.EDIT: Ok I tried changing from where I started (back to the original way it was, starting from tumblr was just another (actually silly) way to try to fix it. It still breaks right after the first ->, so displays "posts[0] AS $post....ect" on screen.This is the first thing I've ever done in PHP so there might be something obvious that I should have set up beforehand or something. I don't know and couldn't find anything like that though.
 
Back
Top