rjsteen

rjsteen

I have been looking at the available Elixir/Erlang libraries for working with XML and cannot seem to find something that can do everything Nokogiri (Ruby) does.

I have come down to sweet_xml for parsing xml and erlsom for validating xml. I could use xml_builder to build xml or even erlsom. I have not found a library other than erlsom that does all three- parsing, building and validating. I am also an Elixir newbie so I could be missing something.

What would you all suggest? Using a combination of libraries as mentioned above or is there something else out there I’m missing?

Showing Posts 16 to 7

silverdr

silverdr

TNX! Shall explore this path

al2o3cr

al2o3cr

Most public functions in that file take an optional options_list() argument, which can include a fetch_fun:

https://github.com/erlang/otp/blob/845adc7375b221359e387e3837fb5b2242fecaa5/lib/xmerl/src/xmerl_xsd.erl#L30-L50

silverdr

silverdr

Thank you, although I am wondering whether that’s feasible. I mean w/o reimplementing the thing. Is there a place where I could simply provide the fun?

al2o3cr

al2o3cr

I suspect you may need to supply your own fetch_fun option to xmerl_xsd - the default one only matches http: URIs:

https://github.com/erlang/otp/blob/master/lib/xmerl/src/xmerl_xsd.erl#L5249-L5250

silverdr

silverdr

So… it’s been some time since the last post here :slight_smile: and I have some XMLs to process both directions, with XSD support, and I have problem with external resources there. The XSD uses types definitions referenced as external URL (https:// …) when trying to process the XSD (using :xmerl_xsd.process_schema/1) I get :enoent error related to those external resources.

Is there a way to make xmerl[_xsd] fetch them as needed?

veverkap

veverkap

Thanks!

chulkilee

chulkilee

Check out GitHub - chulkilee/ex_scems: A Sentinel Cloud EMS Web Services wrapper in Elixir · GitHub.

Basically I use SweetXml.transform_by/2 and then pass map into struct!/2.

I wrote it a while ago, so I may want to do it different way now though :slight_smile:

veverkap

veverkap

How did you setup sweet_xml to parse XML into a hierarchy of structs?

I’m trying to get it using the @schema and i don’t know how to nest more complicated structs

gon782

gon782

This is also the case with Scrape and it actually suffers some compilation issues because of having to compile rust in a rather brittle way. The only way I could make it work was to actually go into the deps manually and run a cargo command.

Still good, though.

kamidev

kamidev

Yes, Meeseeks is very nice! I recently used it for a small scraper and it was faster and easier to use than anything else I looked at.

Note that it’s fast because it uses a NIF to wrap the Rust library html5ever. I installed Rust (using asdf), added Meeseeks to my deps and it just worked. But it’s good to be aware of the extra dependency.

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
thiagogsr
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews