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?

First 10 of 23 Posts Switch mode

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

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
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
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement