-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List items with attributes #163
Comments
Yes, thanks this would suit for what I want to achieve |
After consideration, it is not completely what I need. Below a possible solution: {
'searchword' : [
{'@attrs': {'xml:lang': 'nl'}, '@val': 'Adembescherming'},
{'@attrs': {'xml:lang': 'en'}, '@val': 'Breathing protection'}
]
} Which should result in: <searchword xml:lang="nl">Adembescherming</searchword>
<searchword xml:lang="en">Breathing protection</searchword> I hope this helps |
{
"vehicle" : {
"attrs": "transportation-mode",
"val": ["Bike", "Bus", "Tram"]
}
} may be converted to <?xml version="1.0" encoding="UTF-8"?>
<vehicle>
<attrs>transportation-mode</attrs>
<val>Bike</val>
<val>Bus</val>
<val>Tram</val>
</vehicle> |
@javadev what do you mean with your comment? An example of the code behaviour at the moment? |
Too many implementation possibilities 🤨. Although I have yet to find out which could be implemented at all, I don't have a strong preference yet. |
I see @EstherFranssen That your suggestion is similar to option 5 so I think I'll make an attempt at it. |
Guys, thanks for all the comments and for providing implementation ideas. I
will look into each of these and give my opinion by this weekend, and
possibly a PR for it as well.
…On Tue, 3 Jan 2023 at 19:53, Jeroendevr ***@***.***> wrote:
I see @EstherFranssen <https://github.com/EstherFranssen> That your
suggestion is similar to option 5 so I think I'll make an attempt at it.
—
Reply to this email directly, view it on GitHub
<#163 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDITSKZB4RKZNH36USLKTWQQY7PANCNFSM6AAAAAATBOGOZ4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Thanks and Regards,
Vinit Kumar
|
Nice, awesome. I have added a PR with a unit test if we are going for option 5. Let me know if I can do anything else for you. |
@EstherFranssen A new release of json2xml has been released and thanks to the great work of @Jeroendevr, we have list with attributes support live. Please grab the latest code from https://json2xml.readthedocs.io/en/latest/, https://pypi.org/project/json2xml/3.21.0/ and see if it solves your use case. If there are some bugs, please create a ticket. |
Thanks @vinitkumar, @Jeroendevr, this is great! |
Concept issue
Is your feature request related to a problem? Please describe.
When creating a xml from a list and wanting to add attributes to it seems impossible.
Describe the solution you'd like
Something that should result in
Describe alternatives you've considered
Option 1 - Multiple sets of attrs and values after each other
Option 2
Option 3 - For every value an attr with values as list
Option 4 - For every value an attr as a sequence in a list
Option 5 - For every value an attr as a sequence in a listv2
Additional context
It sounds similar to issue #146 but I don't want to hijack that issue to promote my own feature request.
@EstherFranssen could you confirm this would be a workable solution?
Edit jan-2023 Updated solution I'd like
The text was updated successfully, but these errors were encountered: