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?
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?