JeyHey

JeyHey

Xml library with control over how empty tags are printed

Hello

I’m looking for a (reliable, stable) library for printing data in an xml-format. What I additionally need is the ability to specify that empty tags should not be abbreviated (don’t ask, banks are apparently not able to read and understand specifications). For example, an empty tag some_tag should be printed like so:

<some_tag></some_tag>

and never like so (which is allowed according to the specification and also the preferred way):

<some_tag/>

I looked at xmerl and did not find this feature. Which other libraries do exist that allow this ?

Marked As Solved

mudasobwa

mudasobwa

Creator of Cure

I added this functionality to xml_builder_ex.

See empty: :full option in a call to generate/2.

Also Liked

JeyHey

JeyHey

It works almost like expected. The only problem is that empty tags have indentation whitespaces as content. I think deleting lines 171 and 192 in file lib/xml_builder.ex would fix it.

Also, the readme defines the dependency as {:xml_builder, "~> 3.1"} but it only works if it is defined as {:xml_builder_ex, "~> 3.1"}.

mudasobwa

mudasobwa

Creator of Cure

It’s not a problem, it is how it worked by design. There is an ability to provide a format: option to generate/2 and all the formatters would use it. Just gluing empty tags would violate this, so you always had an option to do format: [*: :indent, tag1: :none, tag2: :none].

But since it’s a common expectation to have empty tags glued, I added empty: :squeezed alongside empty: :full which does not respect the format setting and glues empty tags in (example from tests.)

Where Next?

Popular in Questions Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

We're in Beta

About us Mission Statement