Enable selection of quoting style during etree.tostring
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
From https:/
=======
I have created a basic xml tree using lxml tutorial:
```
from lxml import etree
root = etree.Element(
root.append( etree.Element(
child2 = etree.SubElemen
child3 = etree.SubElemen
print(etree.
```
This produces the following:
```
<?xml version='1.0' encoding='UTF-8'?>
<root>
<child1/>
<child2/>
<child3/>
</root>
```
My question is, how to produce xml file with double quoted file header, i.e.
```
<?xml version="1.0" encoding="UTF-8"?>
```
=======
The specific issue would be (master at-the-time: 68cf93c4827ea74
https:/
However, it would be nice if every other instance of "quote style" would be configurable too, if any.
---------
## -- PLEASE PROVIDE THE FOLLOWING INFORMATION: --
Python : sys.version_
lxml.etree : (4, 1, 1, 0)
libxml used : (2, 9, 7)
libxml compiled : (2, 9, 7)
libxslt used : (1, 1, 32)
libxslt compiled : (1, 1, 32)
## -----
Changed in lxml: | |
status: | New → Won't Fix |
As the SO discussion suggests, the output is perfectly correct. It's the "quality gate" that needs fixing.
Even if there was a way in lxml to change the quoting, it would only apply to a few parts of the output, since most of the serialisation is done by libxml2, which does not have a way to configure it.
Writing your own declaration into a file before serialising the rest of the XML seems like a good enough work-around, though, that gives complete control over the spelling. I don't think there is anything to improve here.