mentalist Posted February 9, 2010 Share Posted February 9, 2010 I'm playing with twitter. I'm receiving an xml document and using preg_match_all on it. What i'm wanting to do is split it on the <user> tags. This is the code i'm trying... preg_match_all('#<user>([.\s\n]*)</user>#',$s,$matches); I've tried variations, all to no avail. I'm actually unsure about the hash / pound 's at either end, but the example I got it from uses them... Not sure if it's the angle brackets and such that's playing up... Thanks for any help! Quote Link to comment Share on other sites More sharing options...
trq Posted February 9, 2010 Share Posted February 9, 2010 There is the simplexml extension which is useful for parsing xml. Quote Link to comment Share on other sites More sharing options...
cags Posted February 9, 2010 Share Posted February 9, 2010 The hash signs are correct and are one of many characters that you can use for delimiters. The problem is since you use the dot assertion inside a character class it has no special meaning, it will literally match only a dot. So you pattern looks for user tags that contains 0 or more fullstops or white-space characters. I assume your user tags have more than that between them. But as thorpe said, you should really use a proper xml parser. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.