marcuslankenau

marcuslankenau

I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to parse the xml content that I receive. But it doen’t feel natural to use.

Now I have to generate xml content as well. I have use cases like cutting nodes (with xpath) from one document, enriching that part with other data and generating a new document. I don’t feel like I can do that easily with SweetXML or floki (that I really like).

I put something together that almost covers what I need, have to continue on it. Maybe someone is interested in the project as well:

https://github.com/mlankenau/elixml

Marcus

Showing Posts 1 to 10

OvermindDL1

OvermindDL1

For note, the BEAM has a built-in xml library called xmerl (actually very powerful with multiple processing methods). :slight_smile:

However, being built-in it is very erlang’y, so elixir XML implementations and/or wrappers are nice. :slight_smile:

BrightEyesDavid

BrightEyesDavid

Would using XSLT be an option? Xslt – Xslt v0.1.1

I don’t know where the data you need to add comes from, but if it too is XML maybe you could use XSLT’s document() function? (As it happens I was doing this the other day, but from bash, not Elixir.)

marcuslankenau

marcuslankenau OP

We have a couple of datasource (SOAP/XML, FTP/XML). We transform this data to json that we use internally. Normally we transform one XML to one JSON document. But there are exceptions where we need to combine different XMLs to reuse our existing mappings. I am not keen to use XML but i have to.

OvermindDL1

OvermindDL1

Oh I know that all too well. ^.^;

dimitarvp

dimitarvp

This library can really use some more documentation.

Example: if I want to find certain elements via an XPath expression and then modify their contents and store the result as a new XML, how would I do that with Elixml?

marcuslankenau

marcuslankenau OP

I agree. The documentation is very basic and only showing some use cases with examples.

For your specific question:
You could parse the XML and manipulate the maps/array structure and store it as XML again. Not very convenient. Or we could think about having a map that works like the find and change nodes.

Why not open an issue with your feature request in the Github project and I will take care. Or you can contribute to the project if you like.

dimitarvp

dimitarvp

Well, problem is, I have a work assignment and I am not looking at it through the eyes of an OSS contributor. I am looking for a ready-made solution.

I can file an issue alright, but offering a PR is highly unlikely at this point.

Cruz

Cruz

Funny. I was about to embark on a little project that requires the parsing of a large XML file. Definitely great to see more efforts in this area!

While doing some research, I found Meeseeks:

https://github.com/mischov/meeseeks

@OvermindDL1 has recommended it in other post. Did you try it? If so, what was missing that you needed?

Thanks a lot

OvermindDL1

OvermindDL1

I use Meeseeks for both HTML and XML parsing, it’s awesome for both. The CSS and XPath selectors are supported on both HTML and XML parsing in it.

It does require having Rust’s compiler toolchain installed though.

dimitarvp

dimitarvp

What about mutating the XML structure and writing it back to disk? Can it do that in combination with XPath?

Where Next? Top

Trending in Announcing Top

restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 12366 136
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
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
ausimian
Castle is a package I put together to assist with building Elixir releases capable of being live-upgraded via the ‘official’ release hand...
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
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

Other Trending Topics Top

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
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
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews