Blank CDATA with PHP and SimpleXML - Default

« Return to Article

Request

$url = 'http://www.devshed.com/rss-feeds-11.xml';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3); 

// Execute, close connection
$curl_result = curl_exec($ch);
curl_close($ch); 

// Convert to SimpleXML
$xml = new SimpleXMLElement($curl_result);
print_r($xml);

Response

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [version] => 2.0
        )

    [channel] => SimpleXMLElement Object
        (
            [title] => PHP - Web Developer Tutorials
            [link] => Array
                (
                    [0] => http://www.devshed.com
                    [1] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [rel] => hub
                                    [href] => http://devshednet.superfeedr.com/
                                )

                        )

                    [2] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [rel] => self
                                    [href] => http://www.devshed.com/rss-feeds-11.xml
                                )

                        )

                )

            [comment] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                        )

                    [1] => SimpleXMLElement Object
                        (
                        )

                )

            [description] => PHP Tutorials at Dev Shed.  DevShed is a community focused on both beginner and advanced tutorials in Java, C, PHP, Python, MySQL and Ruby-on-rails...amongst others.
            [language] => en-us
            [lastBuildDate] => Thu, 09 Feb 2012 05:04:14 -0500
            [pubDate] => Thu, 09 Feb 2012 05:04:14 -0500
            [item] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [title] => PHP Closures as View Helpers: Lazy-Loading File Data
                            [pubDate] => Mon, 30 Jan 2012 08:00:07 -0500
                            [link] => http://www.devshed.com/c/a/PHP/PHP-Closures-as-View-Helpers-LazyLoading-File-Data/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-Closures-as-View-Helpers-LazyLoading-File-Data/
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [title] => Using PHP Closures as View Helpers
                            [pubDate] => Tue, 24 Jan 2012 11:06:09 -0500
                            [link] => http://www.devshed.com/c/a/PHP/Using-PHP-Closures-as-View-Helpers/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Using-PHP-Closures-as-View-Helpers/
                        )

                    [2] => SimpleXMLElement Object
                        (
                            [title] => PHP File and Operating System Program Execution Functions
                            [pubDate] => Tue, 03 Jan 2012 12:00:04 -0500
                            [link] => http://www.devshed.com/c/a/PHP/PHP-File-and-Operating-System-Program-Execution-Functions/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-File-and-Operating-System-Program-Execution-Functions/
                        )

                    [3] => SimpleXMLElement Object
                        (
                            [title] => PHP: Effects of Wrapping Code in Class Constructs
                            [pubDate] => Wed, 28 Dec 2011 08:00:06 -0500
                            [link] => http://www.devshed.com/c/a/PHP/PHP-Effects-of-Wrapping-Code-in-Class-Constructs/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-Effects-of-Wrapping-Code-in-Class-Constructs/
                        )

                    [4] => SimpleXMLElement Object
                        (
                            [title] => PHP: Building Concrete Validators
                            [pubDate] => Wed, 21 Dec 2011 08:00:05 -0500
                            [link] => http://www.devshed.com/c/a/PHP/PHP-Building-Concrete-Validators/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-Building-Concrete-Validators/
                        )

                    [5] => SimpleXMLElement Object
                        (
                            [title] => Sanitizing Input with PHP
                            [pubDate] => Mon, 12 Dec 2011 11:30:05 -0500
                            [link] => http://www.devshed.com/c/a/PHP/Sanitizing-Input-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Sanitizing-Input-with-PHP/
                        )

                    [6] => SimpleXMLElement Object
                        (
                            [title] => Executing Shell Commands with PHP
                            [pubDate] => Wed, 07 Dec 2011 09:30:04 -0500
                            [link] => http://www.devshed.com/c/a/PHP/Executing-Shell-Commands-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Executing-Shell-Commands-with-PHP/
                        )

                    [7] => SimpleXMLElement Object
                        (
                            [title] => Handling File Data with PHP
                            [pubDate] => Tue, 29 Nov 2011 08:00:06 -0500
                            [link] => http://www.devshed.com/c/a/PHP/Handling-File-Data-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Handling-File-Data-with-PHP/
                        )

                    [8] => SimpleXMLElement Object
                        (
                            [title] => File Security and Resources with PHP
                            [pubDate] => Wed, 23 Nov 2011 10:00:07 -0500
                            [link] => http://www.devshed.com/c/a/PHP/File-Security-and-Resources-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/File-Security-and-Resources-with-PHP/
                        )

                    [9] => SimpleXMLElement Object
                        (
                            [title] => ArrayObject PHP Class Examples
                            [pubDate] => Wed, 16 Nov 2011 13:00:05 -0500
                            [link] => http://www.devshed.com/c/a/PHP/ArrayObject-PHP-Class-Examples/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/ArrayObject-PHP-Class-Examples/
                        )

                    [10] => SimpleXMLElement Object
                        (
                            [title] => ArrayObject PHP Class: An Introduction
                            [pubDate] => Wed, 16 Nov 2011 12:30:06 -0500
                            [link] => http://www.devshed.com/c/a/PHP/ArrayObject-PHP-Class-An-Introduction/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/ArrayObject-PHP-Class-An-Introduction/
                        )

                    [11] => SimpleXMLElement Object
                        (
                            [title] => Getting File System Data with PHP
                            [pubDate] => Tue, 15 Nov 2011 08:00:06 -0500
                            [link] => http://www.devshed.com/c/a/PHP/Getting-File-System-Data-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Getting-File-System-Data-with-PHP/
                        )

                    [12] => SimpleXMLElement Object
                        (
                            [title] => PHP Tools for Working with the File and Operating System
                            [pubDate] => Wed, 09 Nov 2011 12:00:07 -0500
                            [link] => http://www.devshed.com/c/a/PHP/PHP-Tools-for-Working-with-the-File-and-Operating-System/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-Tools-for-Working-with-the-File-and-Operating-System/
                        )

                    [13] => SimpleXMLElement Object
                        (
                            [title] => Working with the File and Operating System with PHP
                            [pubDate] => Fri, 04 Nov 2011 08:30:05 -0400
                            [link] => http://www.devshed.com/c/a/PHP/Working-with-the-File-and-Operating-System-with-PHP/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/Working-with-the-File-and-Operating-System-with-PHP/
                        )

                    [14] => SimpleXMLElement Object
                        (
                            [title] => PHP Proxy Patterns: Completing a Blog
                            [pubDate] => Mon, 31 Oct 2011 00:14:45 -0400
                            [link] => http://www.devshed.com/c/a/PHP/PHP-Proxy-Patterns-Completing-a-Blog/
                            [description] => SimpleXMLElement Object
                                (
                                )

                            [category] => PHP
                            [guid] => http://www.devshed.com/c/a/PHP/PHP-Proxy-Patterns-Completing-a-Blog/
                        )

                )

        )

)

Donate

If you found this article useful and would like to see more like it this please consider making a donation.