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
Add default_namespace argument to xml.etree.ElementTree.tostring() #80408
Comments
default_namespace is often used when serializing ET elements. tostring() is mainly a wrapper around ElementTree.write(), and it is therefore natural that it mirrors write's argument. tostring() already passes encoding, method and short_empty_elements to write. |
The feature seems reasonable to me and the patch looks good. |
See also bpo-31256. I do not know what is better: make tostring() to accept all options of write(), or keep it simpler. What strategy lxml supports? |
lxml does not support the "default_namespace" option specifically (because its tree model preserves namespace prefixes), but it generally makes all (justifiable) serialisation options available to both tostring() and ET.write(). I think the same should apply to ElementTree. Both the "default_namespace" and "doctype" options seem useful regardless of the serialisation target. |
I will add xml_declaration and push to the existing PR. |
I pushed changes to the PR. I also added xml_declaration and default_namespace to the tostringlist() method. |
Thank you for you contribution. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: