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>'); PHP: 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"/> Code (markup): 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?
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); PHP: for example
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
Thanks Shawn, I appreciate it. Also came across http://magpierss.sourceforge.net/ for those wanting to explore rss feeds