NYCPHP Meetup

[nycphp-talk] parsing RSS feeds using the Unserializer

Adam Maccabee Trachtenberg adam at trachtenberg.com
Mon Apr 4 13:07:37 EDT 2005


print ${"dc:creator"};

-adam

On Mon, 4 Apr 2005, Dallas DeVries wrote:

> As you can see PHP did infact set the attribute of an object to have a colon
> in it with a corresponding value. Matching tags and parsing out the colons
> before I unserialize seems like an unecessary hack to avoid this but perhaps
> thats all I'm left with using this Class.
>
> -Dallas
>
> On Apr 4, 2005 8:02 AM, Hans Zaunere <lists at zaunere.com> wrote:
> >
> >   I'm using the Unserialize pear class to parse out an RSS feed.
> >
> > The problem I'm having is accessing the attribute with the colon in it.
> > Does anyone know how to access this element such as this?
> >
> > $options = array('complexType' => 'object',"parseAttributes" => true,
> > "attributesArray" => false);
> > $unserializer =& new XML_Unserializer($options);
> > $status = $unserializer->unserialize($content);
> > $data = $unserializer->getUnserializedData();
> > foreach($data->channel->item as $item) {
> > echo *$item->dc:creator;*
> >
> > stdClass Object
> > (
> > [title] => Diamond Mind 2005 Predicted Standings Out
> > [link] => http://ussmariner.com/?p=2378
> > [comments] => http://ussmariner.com/?p=2378#comments
> > [pubDate] => Thu, 31 Mar 2005 05:11:34 +0000
> > [dc:creator] => DMZ
> > [category] => General baseball
> > [guid] => http://ussmariner.com/?p=2378
> >
> >   Variables shouldn't have a colon in their name.
> >
> >  http://www.php.net/manual/en/language.variables.php
> >
> >  H
> >
> > _______________________________________________
> > New York PHP Talk Mailing List
> > AMP Technology
> > Supporting Apache, MySQL and PHP
> > http://lists.nyphp.org/mailman/listinfo/talk
> > http://www.nyphp.org
> >
> >
>

-- 
adam at trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!



More information about the talk mailing list