Skip to content
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

Is there a way to not include the item tag in a list? #39

Open
ghost opened this issue May 29, 2015 · 10 comments
Open

Is there a way to not include the item tag in a list? #39

ghost opened this issue May 29, 2015 · 10 comments

Comments

@ghost
Copy link

ghost commented May 29, 2015

No description provided.

Euphorbium added a commit to Euphorbium/dicttoxml that referenced this issue Nov 8, 2015
@quandyfactory
Copy link
Owner

The latest version includes the ability to customize the name of the item elements. Does this change meet your requirements?

@patrick91
Copy link

@Euphorbium can you create a PR for your fix? I'm sure it is a welcome feature :)
I just used your fork and it worked fine :)

@Euphorbium
Copy link

@patrick91 pull request #44 opened on Nov 8, 2015

@patrick91
Copy link

Oh, sorry I thought I checked! Hope @quandyfactory will merge that soon then :)

@arslanqadeer
Copy link

What i don't want tag in my XML? It is always there...i can change its name but i cannot remove this. is there any way to remove it?

@ssvaddiparthy
Copy link

@arslanqadeer what I did was to add a None tag, convert the XML to string, replace the None tag with empty string. Here is how I did:

dicttoxml.dicttoxml(....., item_func=lambda x: None).replace('<None>', '').replace('</None>', '')

This solved my problem but I am sure this needs to be inbuilt.

@Pechi77
Copy link

Pechi77 commented Aug 7, 2019

@vaddipar works fine, thank you 👍 but we need to convert the output to string object

result = dicttoxml.dicttoxml(....., item_func=lambda x: None)
result = str(result).replace('<None>', '').replace('</None>', '')

@akarev0
Copy link

akarev0 commented Dec 17, 2021

any updates here in almost 2022?)

@DreamZeppelin
Copy link

DreamZeppelin commented Dec 21, 2021

@akarev0 : I encountered the same problem. My intermediate solution is to convert the object to string and do a replace:

xml_str = str(dicttoxml.dicttoxml(json_object, attr_type=False, custom_root="MYROOT")).replace("<item>", "").replace("</item>", "")

(similar to solution that ssvaddiparthy mentioned)

@akarev0
Copy link

akarev0 commented Dec 21, 2021

@DreamZeppelin thanks, used the same approach, but it should be in library core I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants