Hello,
This issue is coming when i update drupal core to 8.4.2.
In my custom module I used SimpleXmlElement to fetch xml content. That's why I used "Symfony\Component\DependencyInjection" namespace. But when i updated the drupal core I got "Class 'Symfony\Component\DependencyInjection\SimpleXMLElement' not found" PHP Fatal error.
I found that SimpleXMLElement.php is missing in "vendor/symfony/dependency-injection" folder.
So,I manually added SimpleXMLElement.php in this folder, then the error was gone. But I know this is not a solution.
I have searched a lot but couldn't able to know why it's deprecated on drupal 8.4.2.
Can anyone advise how to use SimpleXMLElement to fetch XML object as in Drupal 8.4.2's code, or is there any other replacement for it?
Thanks in advance.
Comments
Comment #2
cilefen commentedComment #3
dawehnerDo you mind showing your code, like for example the services.yml file? Otherwise its a bit tough to really help, beside providing some random guessing.
Comment #4
sohinicp commentedOk. My requirement is very simple just want to read the rss feed & put it in the array.
Here is my code ->
I have created the functionality on Controller.php file
namespace Drupal\custom_job\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\SimpleXMLElement;
class AdminPage extends ControllerBase {
public function getJobDetails() {
$xmlUrl = "http://XXX/rss/"; // XML feed file/URL
$content = file_get_contents($xmlUrl);
if ($content == '') {
return '';
}
else {
$x = new SimpleXmlElement($content);
$i = 0;
foreach ($x->channel->item as $entry) {
$temp = (string) $entry->category;
$data[$i]['category'] = $temp;
.........
}
}
}
}
I got the above error when i updated drupal core to 8.4.2.
Thank you!
Comment #5
dawehnerHere is the code which probably would work:
Comment #6
sohinicp commentedOhh! it works. Thanks a lot @dawehner
Comment #7
cilefen commented