How to get content-Element from XML rss feed using PHP?


how can I get the content-Element from XML? Other solutions on stackoverflow could not help me, I'm doing something wrong.. This is how I read the feed:

            $content = file_get_contents('some feed url');
            $x = new SimpleXmlElement($content);

            foreach($x->channel->item as $entry) {
                $chi = $entry->children('content', true)->encoded;





Try following code:

$x = new SimpleXmlElement($str);
$x->registerXPathNamespace('content', '');

$result = $x->xpath('//channel/item/content:encoded');
if(count($result) > 0) {
    foreach($result as $element) {
        echo (string)$element . "\n";

People are also looking for solutions to the problem: php - Group and nest routes in Symfony 3


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.