What RSS parser should I use in PHP?
My defacto answer will be “have you tried SimplePie?”, it’s a very good XML parser but you’ll have to have a look at their demo to see how it handles broken feeds đŸ™‚
My defacto answer will be “have you tried SimplePie?”, it’s a very good XML parser but you’ll have to have a look at their demo to see how it handles broken feeds đŸ™‚
Found something that I wanted: Google’s AJAX Feed API has a load feed and lookup feed function (Docs here). a) Load feed provides the feed (and feed status) in JSON b) Lookup feed provides the RSS feed for a given URL Theres also a find feed function that searches for RSS feeds based on a … Read more
This should give you an idea on how to do it: using System.Linq; using System.ServiceModel.Syndication; using System.Xml; using System.Xml.Linq; SyndicationFeed feed = reader.Read(); foreach (var item in feed.Items) { foreach (SyndicationElementExtension extension in item.ElementExtensions) { XElement ele = extension.GetObject<XElement>(); Console.WriteLine(ele.Value); } }
See http://msdn.microsoft.com/en-us/library/bb943474.aspx http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx http://msdn.microsoft.com/en-us/library/bb943480.aspx Basically there is a lot of stuff in the .Net 3.5 framework that does the grunt-work of parsing and representing feeds; it’s not hard to write a 30-line app that takes in a feed URL and downloads the feed and prints the title and author of all the items, for example. … Read more
Add System.ServiceModel in references Using SyndicationFeed: string url = “http://fooblog.com/feed”; XmlReader reader = XmlReader.Create(url); SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); foreach (SyndicationItem item in feed.Items) { String subject = item.Title.Text; String summary = item.Summary.Text; … }
You want https://github.com/whatever/commits/master.atom, like for the Cloudera flume repository it’s https://github.com/cloudera/flume/commits/master.atom.
Try this: DateTime today = DateTime.Now; String rfc822 = today.ToString(“r”); Console.WriteLine(“RFC-822 date: {0}”, rfc822); DateTime parsedRFC822 = DateTime.Parse(rfc822); Console.WriteLine(“Date: {0}”, parsedRFC822); The “r” format specifier passed into DateTime’s ToString() method actually yields an RFC-1123-formatted datetime string, but passes as an RFC-822 date as well, based on reading the specification found at http://www.w3.org/Protocols/rfc822/#z28. I’ve used this … Read more
The .NET framework exposes classes that handle syndation: SyndicationFeed etc. So instead of doing the rendering yourself or using some other suggested RSS library why not let the framework take care of it? Basically you just need the following custom ActionResult and you’re ready to go: public class RssActionResult : ActionResult { public SyndicationFeed Feed … Read more
As you already know, SimpleXML lets you select an node’s child using the object property operator -> or a node’s attribute using the array access [‘name’]. It’s great, but the operation only works if what you select belongs to the same namespace. If you want to “hop” from a namespace to another, you can use … Read more
You need to use delimiters with regexes in PHP. You can use the often used /, but PHP lets you use any matching characters, so @ and # are popular. Further Reading. If you are interpolating variables inside your regex, be sure to pass the delimiter you chose as the second argument to preg_quote().