aniesh82 Posted October 20, 2008 Share Posted October 20, 2008 Hi, I have to test whether the returned data is a valid RSS file contents or not. For doing that, I can check the header along with the data. But I wish to check the structure of the RSS and I only needed RSS feed of version 2.0. Can someone correct this Reg Expr? Example URL: (view page source) http://rss.news.yahoo.com/rss/topstories $pattern = '#<\?xml .*(version=\"1.0\").*\?>(\s)*<rss .*(version=\"2.0\").*>(\s)*<channel>(\s)*<title>(.*)</title>(\s)*.*<description>.*</description>.*(<item>.*</item>)*#'; Upto description it works well. But after that, it doesn't return the expected result. Also I have to check the Two Ending tags. "</channel></rss>" .. Thank You, Joseph. Quote Link to comment https://forums.phpfreaks.com/topic/129160-rss-content-validation-using-regular-expr/ Share on other sites More sharing options...
DarkWater Posted October 20, 2008 Share Posted October 20, 2008 I think you could just use like, simplexml_load_string and see if it returns false. If it does, the XML was invalid. Quote Link to comment https://forums.phpfreaks.com/topic/129160-rss-content-validation-using-regular-expr/#findComment-669640 Share on other sites More sharing options...
aniesh82 Posted October 20, 2008 Author Share Posted October 20, 2008 Yes, that is a method to validate the XML. But I also wnat to check whether it is of RSS version 2.0 or not Quote Link to comment https://forums.phpfreaks.com/topic/129160-rss-content-validation-using-regular-expr/#findComment-669661 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.