ox icon indicating copy to clipboard operation
ox copied to clipboard

Request to include a new mode to load which prepends xml attributes with a given string or a default

Open mandos21 opened this issue 2 years ago • 1 comments

At the moment there is no way of discerning if the hash returned from Ox.load(xml, mode: :hash) contains attributes, and if it does, which keys they are. Another hash mode ie :hash_labeled_attrs that prepends returned attributes with "attr_" or something similar would be incredibly useful.

mandos21 avatar Mar 16 '22 14:03 mandos21

There are probably a dozen or more ways to include attributes in a hash. It isn't feasible to support all the variations people could come up with. The :hash and :hash_no_attrs are two of the common approaches. For others there is the SAX parser where you can build what ever is desired. I might caution you on using the addition of a "attr_" prefix approach though as a general solution as an element name of "attr_bucket" for example would be mistaken for an attribute.

ohler55 avatar Apr 01 '22 23:04 ohler55