OK now that we have all the content… We are ready to display it…
But before that we should check what way is the XML document structured…
For that paste the $url string in the browser and you’ll see something like this
<!-- Copyright (C) 2000-2004 - Developer Shed, Inc. --> <rss version="2.0"> <channel> <title>Dev Shed - The Open Source Web Development Site</title> <link>http://www.devshed.com</link> <description>mos_rss</description> <language>en-us</language> <lastBuildDate>Tue, 27 Apr 2004 12:39:24 -0400</lastBuildDate> <item> <title>The Power of CSS</title> <link> http://www.devshed.com/c/a/Style-Sheets/The-Power-of-CSS/ </link> <description> CSS or cascading style sheets are used to create a set of styles that can be applied to your fonts, ... </description> </item> ... and many more item tags...
IF you note carefully… The most important tag is the [item] tag, where there are sub tags [title], [link], [description], and these sub tags are at the level 4 The tags [title], [link], [description], [language], [lastBuildDate] which provide the general info of the website are at level 3
Now we just have to use the $vals array and get out the information, we do it using a simple for loop
for ($i=0; $i<count($vals); $i++) { //get the primary info if ($vals[$i]['tag']=="TITLE" && $vals[$i]['level']==3) { $title = $vals[$i]['value']; } if ($vals[$i]['tag']=="LINK" && $vals[$i]['level']==3) { $link = $vals[$i]['value']; } if ($vals[$i]['tag']=="DESCRIPTION" && $vals[$i]['level']==3) { $desc = $vals[$i]['value']; } if ($vals[$i]['tag']=="LASTBUILDDATE" && $vals[$i]['level']==3) { $dt = strtotime($vals[$i]['value']); } //get the main feed if ($vals[$i]['tag']=="TITLE" && $vals[$i]['level']==4) { $arr['title'][] = $vals[$i]['value']; } if ($vals[$i]['tag']=="LINK" && $vals[$i]['level']==4) { $arr['link'][] = $vals[$i]['value']; } if ($vals[$i]['tag']=="DESCRIPTION" && $vals[$i]['level']==4) { $arr['desc'][] = $vals[$i]['value']; } }
OK, Now we have all the required information only !
With havin so much content and articles do you ever run
into any issues of plagorism or copyright violation? My website has a lot of completely unique content
I’ve either written myself or outsourced but it looks like a lot of it is popping it up all over the web without my authorization. Do you know any methods to help reduce content from being ripped off? I’d definitely appreciate it.
I don’t really think anybody is copying my content, however on the net its difficult to control content-jacking ! There are certain sites that “help” you, I don’t know how successfully – ie. http://www.copyscape.com/