fast-xml-parser icon indicating copy to clipboard operation
fast-xml-parser copied to clipboard

how to change the attribute tag name

Open cckowin opened this issue 5 years ago • 4 comments
trafficstars

is there any way to change the attribute tag name using this module like xml2js eg. <test attribute-name="test"></test> to produce a result like this test: { attributeName: "test", }

cckowin avatar Nov 26 '19 12:11 cckowin

I'm glad you find this repository helpful. I'll try to address your issu ASAP. You can watch the repo for new changes or star it.

github-actions[bot] avatar Nov 26 '19 12:11 github-actions[bot]

@cckowin we can currently do the alteration in values only. We can think about to change it for both value and names. Or probably a separate name processor. Thanks

amitguptagwl avatar Nov 26 '19 23:11 amitguptagwl

A processor for tag and attribute names would also allow for case insensitive xml files, just by using (name) => name.toLowerCase().

Tiim avatar Sep 21 '21 07:09 Tiim

We can probably reuse attributeValueProcessor to return an object where the key represents attribute name. However, in this case, user will lose the feature of parsing attribute value to some object.

amitguptagwl avatar Dec 05 '21 07:12 amitguptagwl

https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#transformattributename

amitguptagwl avatar Jan 10 '23 03:01 amitguptagwl