Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

SimpleXML and Reading CDATA Tags

Wednesday, January 30. 2008

While using PHP5, almost everyone knows that SimpleXML is the easiest class to utilize when absorbing data from an XML source (be it XML, Atom, RSS, etc...). But, there are instances where things aren't as smooth as one would hope. I was reading in some RSS feeds from WeatherBug the other day, and was all fine and dandy, until I came to an annoying little snippet of code within the feed.


When I got to that data, SimpleXML couldn't retrieve it. When I did a dump of the entire feed, SimpleXML expressed the description tags as being empty. Ok...so how the heck can we get at it?

It's much simpler than one would expect. You forcibly convert the value of that field to a string. That's it.


The annoyingly difficult thing about this, is that I knew I wouldn't be able to figure it out on my own, and the PHP docs didn't help with that one. I went to Google, and that took a few tricky searches to find what I needed too!

Source: Using SimpleXML to Parse RSS Feeds

Tip: That link also shows how to traverse different namespaces, just in case your RSS or XML sources use namespaces, which the last time that happened I used a DOMDocument object, which was a little more work than necessary. I wish I knew this back then!

Trackbacks


Trackback specific URI for this entry

    Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73
    No Trackbacks

Comments



    Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_comments.inc.php on line 292

    Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

    Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73
    No comments

Add Comment


Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed

   


Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/brendonk/mysiteonline.org/life/include/db/mysql.inc.php on line 270

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_config.inc.php on line 523

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::enum_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 956

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_spartacus::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_dpsyntaxhighlighter::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_nl2br::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 0

Strict Standards: Declaration of serendipity_event_nl2br::uninstall() should be compatible with serendipity_plugin::uninstall(&$propbag) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_bbcode::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_bbcode/serendipity_event_bbcode.php on line 0

Strict Standards: Declaration of serendipity_event_bbcode::uninstall() should be compatible with serendipity_plugin::uninstall(&$propbag) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_bbcode/serendipity_event_bbcode.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_config.inc.php on line 523

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/serendipity_config.inc.php on line 406

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 32

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::count_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 35

Strict Standards: Non-static method serendipity_plugin_api::count_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 36

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 514

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 572

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 555

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 997

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 1086

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 1156

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_comments.inc.php on line 292

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012