View Full Version : RegEx & XML

06-19-2010, 06:19 PM
Hey guys..... first off, I know I could use stuff like SimpleXML to do this, but I find they are too strict & using methods like below I don't have to worry about the file being perfect as it will just treat it as normal data.

Ok.... so anyway, was wondering if anyone could tell me why this code seems to be matching two items fields at once when I have set it to be ungreedy?

$pattern = '~<item>.*<title>(.+)</title>.*<link>(.+)</link>.*<description>(.+)</description>.*</item>~iU';

$res = preg_match_all($pattern, $data, $matches);

So basically I only get results for each 2nd item as it appears it's matching two items @ once.

Any idea why?