dmarcoux

dmarcoux

Hey everyone,

I would like to parse Atom and RSS feeds in an application I am working on. I’ve looked at the existing packages on Hex to help me with this task and they all seem to be unmaintained. Sure, the world of Atom/RSS feeds isn’t changing much, so once you have a package working, it doesn’t have to change much either. I could fork one of those and fix warnings for the latest Elixir version.

From those packages, fast_rss seems to be the best choice, although I would rather not have to install the Rust compiler only to parse feeds.

I thought about using Elixir Ports to rely on a pre-compiled binary of a RSS/Atom parser from another programming language. This would certainly widen my options, but add complexity.

What would you recommend? Do you have experience with some of the Atom/RSS parsers?

Showing Posts 1 to 10

mayel

mayel

Just to note, fast_rss seems to use rustler_precompiled which means in many cases you won’t need the rust compiler :slight_smile:

garrison

garrison

Last time I ran into this I didn’t like any of the options so I just wrote the parsers by hand using Saxy, which worked great.

I am not a fan of the NIF approach for stuff like this because the BEAM’s guarantees are actually very useful for parsing arbitrary internet content in a multitenant system. Throwing them away feels unwise. At some point I will probably write a new RSS library but it’s not a top priority at the moment.

Schultzer

Schultzer

You can properly write a faster parser in Elixir anyway, NIF comes with huge cost especially if you are moving data back and forth. Good rule of thumb, most BIFs are very simple, I wonder why :thinking:

derek-zhou

derek-zhou

RSS/Atom feeds are small, simple XML files, Floki with its pure Elixir parser works very well on them. I tracked 10s of thousands feeds and have not seen any problem.

garrison

garrison

Because they are meant to be timesliced! But yeah, in general if you’re writing code in a beamlang it’s because you want to take the multitenant side of the tradeoffs rather than the batch processing side.

Does the HTML parser support CDATA? I would think not, right?

It’s very common to embed content in RSS feeds using CDATA (e.g. HTML content). Saxy handles it fine.

dmarcoux

dmarcoux OP

Oh, I totally overlooked that. Good to know, thank you.

dmarcoux

dmarcoux OP

I didn’t know about Saxy and Floki, thank you @garrison and @derek-zhou. I’ll look at both options.

dimitarvp

dimitarvp

Real men use :xmerl!

More on topic, I agree with building your own bespoke thing, especially with a more or less nailed standard like RSS and Atom. They’re not as big.

garrison

garrison

My impression was that real men would be blowing up their atom tables, but it seems like maybe the xmerl sax parser does use strings? I’ll keep that in mind.

It is actually somewhat annoying to parse RSS in practice. The spec is extended in a bunch of places and there is a lot of weird stuff out there in the real world. I do think there’s room for a good RSS package, I just didn’t find one that I liked at the time. I would like to write one but I currently have a storage engine-shaped backlog that I’m trying to squash before the new year :slight_smile:

dimitarvp

dimitarvp

I am a recovering perfectionist (long process). To me you either settle for one good ready-made complete software package, use a library and patch over its imperfections, or roll your own and enrich it on demand.

I have found maintaining other people’s stuff a thankless work that very rarely materializes time and energy savings over long-enough usage so I end up doing either option one or option three. (And option one is very rarely useful if you want to integrate stuff in your own program so you’d use f.ex. Port and such, which becomes a hassle after an hour of work.)

And yes if memory serves :xmerl does not use atoms but it has been years and I might not remember well. Same as for JSON, people overdo the parsing conveniences, I often parse JSON as recursive string-keyed maps and just work with that; Elixir’s excellent pattern-matching does multiple things at once there and is unbeaten by any language in those areas except maybe OCaml / Haskell / Rust (if you can stomach the increased number of coding lines).

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
psy-q
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews