0

most of the rss have an property call content:encoded, so I get it using this

//in a loop { $item_content=$x->item($i)->getElementsByTagName('encoded')->item(0)->nodeValue; } 

but I also experienced error with some blogs that in its rss it doesn't have content:encoded property so I got an error of Trying to get property of non-object. How to I handle this?

1 Answer 1

1

You can use ->length property of the DOMNodelist before pointing out on that item:

$item_content = ''; if($x->item($i)->getElementsByTagName('encoded')->length > 0) { // if it exists, or at least one $item_content = $x->item($i)->getElementsByTagName('encoded')->item(0)->nodeValue; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.