0

I want to parse a xml, but it giving me a blank output.

My code:

$url = 'http://feeds.news.com.au/public/rss/2.0/fs_breaking_news_13.xml';
    $xml = simplexml_load_file($url);
    $title = $xml->item[1]->title;

The $title, gives a blank output.

Plz help.

Thank you Zeeshan

1 Answer 1

2

From the file, it looks like you didn't see that the items are inside of a node named <channel>

$title = (string) $xml->channel->item[1]->title;
Sign up to request clarification or add additional context in comments.

1 Comment

Dont know exactly, but as I remember children are always organized as lists, so you need to add a index to channel too ($xml->channel[0]->item[1]->title;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.