Today when I was making some modifications and additions to my Raspberry Pi Screen Project, I discovered a problem when trying to Parse some XML in PHP on the Raspberry Pi. I was getting some errors which I wasn’t getting when testing on my web hosting.

PHP Notice:  Trying to get property 'item' of non-object in /var/www/html/php/news.php on line 15
[Sun Apr 12 09:49:45.726372 2020] [php7:warn] [pid 465] [client ::1:40094] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /var/www/html/php/news.php on line 15

It turned out that my news ticker that I was adding was trying to parse XML. It turns out that the Raspberry Pi doesn’t have by this by default, I did some googling and tried a few options, however none of them worked with the Raspberry PI. So I came across this simple line of code to install XML for PHP on the Raspberry PI. I though this might help someone in the same boat.

sudo apt-get install php-xml

Simply enter this into your terminal and press enter. Now you will be able to use XML in PHP.