Sport Betting Systems - vBulletin - WoW Gold - PT Cruiser - Wordpress Themes

PDA

View Full Version : Parsing the Blogger rss feed - how?


piniyini
Nov 17th 2004, 2:07 am
Hi guys, I'm trying to parse my blog feed which is at www.toseef.com/atom.xml

I've managed to get the title of the first ten posts, like I wanted, using the following code:


$html = file_get_contents("http://www.toseef.com/atom.xml");
$patterns = "/<title mode=\"escaped\" type=\"text\/html\">(.*)<\/title>/Uis";
preg_match_all($patterns, $html, $matches);

print '<pre>';

$i = 1;
while ($i < 11) {
print_r($matches[1][$i]); $i++; echo("<br>"); } exit('</pre>');


The result can be seen here www.thewizsite.com/img.htm - I've managed to do this because the pattern is matched with an open and close tag.

Getting the link to each post is much more difficult as the code to match is as follows:
<link href="http://www.toseef.com/2004/11/add-your-link-to-this-site-and-others.html" rel="alternate" title="Add Your Link To This Site (and others)" type="text/html"/>

Obviously, I need the text that is in the href section - How do I go about this? I've tried similar stuff to my previous post but I'm not getting anywhere.

Help?

xml
Nov 17th 2004, 5:02 am
Have u tried something like:

preg_match('/<link.*href=["|\'](.*)["|\']/i', $xml, $matches);

digitalpoint
Nov 17th 2004, 6:59 am
You would be better off using PHP's WML parsing ability...

$parser = xml_parser_create('UTF-8');
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);
for example

piniyini
Nov 18th 2004, 5:03 am
Err, Shawn I dont know what you mean, could you give me an example where the code is in use?

And XML I tried code similar to that and cant get it to work ...

I *really* want this to work so that I can display my posts on other sites

digitalpoint
Nov 18th 2004, 8:08 am
There are tons of examples in the PHP documentation at:

http://www.php.net/manual/en/ref.xml.php

piniyini
Nov 18th 2004, 10:22 am
Thanks Shawn, I appreciate it.

Also came across http://magpierss.sourceforge.net/ for those wanting to explore rss feeds