Revision: 24081
Updated Code
at February 20, 2010 04:58 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class oEntry { public $url; public $author; public $date; public $text; function oEntry($url, $author, $date, $text) { $this->url = $url; $this->author = $author; $this->date = $date; $this->text = $text; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new oEntry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPLE XML INPUT (you need to fill out the tags): <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24080
Updated Code
at February 20, 2010 04:57 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class oEntry { public $url; public $author; public $date; public $text; function oEntry($url, $author, $date, $text) { $this->url = $url; $this->author = $author; $this->date = $date; $this->text = $text; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new oEntry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPLE XML INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24079
Updated Code
at February 20, 2010 04:56 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class oEntry { public $url; public $author; public $date; public $text; function Entry($url, $author, $date, $text) { $this->url = $url; $this->author = $author; $this->date = $date; $this->text = $text; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new oEntry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPLE XML INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24078
Updated Code
at February 20, 2010 04:55 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class oEntry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new oEntry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPLE XML INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24077
Updated Code
at February 20, 2010 04:50 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class Entry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new Entry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPLE XML INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24076
Updated Code
at February 20, 2010 04:50 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class Entry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new Entry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> SAMPE XML INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24075
Updated Code
at February 20, 2010 04:49 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class Entry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new Entry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?> INPUT: <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> <link rel="alternate" type="text/html" href="" /> <id></id> <updated></updated> <title></title> <entry> <id></id> <thr:in-reply-to ref="" type="text/html" href=""/> <link rel="alternate" type="text/html" href="" /> <title></title> <author> <name></name> <uri></uri> </author> <content type="html" xml:lang="en-us" xml:base=""> <![CDATA[<p>html text goes here</p>]]> </content> <published>February 20, 2010 2:23 AM</published> </entry> </feed>
Revision: 24074
Updated Code
at February 20, 2010 04:39 by abbey
Updated Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class Entry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new Entry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach ?>
Revision: 24073
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 20, 2010 04:39 by abbey
Initial Code
<?php error_reporting(E_ALL); // shows all errors, remove this on live sites $feedURL = 'http://mydomain.com/rss/example.xml'; $getFILE = get_content($feedURL) or die("feed not loading"); $xml = simplexml_load_string($getFILE, NULL, LIBXML_NOCDATA); // Set CDATA as text nodes $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); // define namespace atom class Entry { public $url; public $author; public $date; public $entry; function Entry($url, $author, $date, $entry) { $this->url = $url; $this->author = $author; $this->date = $date; $this->entry = $entry; } } foreach($xml->xpath('atom:entry') as $entry) { // array of objects $e[] = new Entry($xml->link['href'], $entry->author->name, $entry->published, $entry->content); } // end foreach
Initial URL
Initial Description
i could put a demo of this in action if you want
Initial Title
PHP: Creating an array of objects to store atom rss data
Initial Tags
object, array, xml
Initial Language
PHP