runeveryday Posted July 27, 2009 Share Posted July 27, 2009 $feed=file_get_contents('URL'); $rss=new SimpleXmlElement($feed); foreach($rss->channel->item as $entry) {echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></p>";} who can tell me what the $rss->channel->item mean. in php,i found state a class's format is class classname{...;} when refer the content of the class,the format is $variablename=new classname, $variablename->the content of the class,however,in the above example,i found there is now state channel in SimpleXmlElement($feed);why? i am a beginner of php and expect some can explain these details. thank you! Link to comment https://forums.phpfreaks.com/topic/167562-rss-feed/ Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 The simplexml class will hold the properties of the xml document, no matter what it looks like (as long as it's proper xml). Channel and item is a result of the structure of RSS. Link to comment https://forums.phpfreaks.com/topic/167562-rss-feed/#findComment-883631 Share on other sites More sharing options...
runeveryday Posted July 27, 2009 Author Share Posted July 27, 2009 thanks for you response!what a pity, i can't understand that.maybe i know XML and RSS not much.are there some articles can help me understand these.would you mind giving me some tips. Link to comment https://forums.phpfreaks.com/topic/167562-rss-feed/#findComment-883643 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Exactly what is it that you don't understand? The structure of xml and rss or objects and classes? That's kind of two very different things Link to comment https://forums.phpfreaks.com/topic/167562-rss-feed/#findComment-883658 Share on other sites More sharing options...
abazoskib Posted July 27, 2009 Share Posted July 27, 2009 $feed=file_get_contents('URL'); $rss=new SimpleXmlElement($feed); foreach($rss->channel->item as $entry) {echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></p>";} who can tell me what the $rss->channel->item mean. in php,i found state a class's format is class classname{...;} when refer the content of the class,the format is $variablename=new classname, $variablename->the content of the class,however,in the above example,i found there is now state channel in SimpleXmlElement($feed);why? i am a beginner of php and expect some can explain these details. thank you! $rss is an object. channel could be a function of the object. item could be a variable of the object. Fairly simple if you understand OOP. Link to comment https://forums.phpfreaks.com/topic/167562-rss-feed/#findComment-883666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.