[lxml-dev] Standalone declaration

Hi, i am new with lxml and is great, i created an xml now i want to make standalone declaration in my structure, how i can do it? i search in docs but i didnt good results. Thx in advance -- [b]question = (to) ? be : !be; .[/b]

Hi, Ovnicraft wrote:
i created an xml now i want to make standalone declaration in my structure, how i can do it?
There isn't currently a way to set the flag programmatically, but you can just parse in the declaration like this: doc = etree.fromstring( '<?xml version="1.0" standalone="true"?><root/>') root = doc.getroot() root[:] = your_content_elements Stefan

Ovnicraft wrote:
Sorry, make that doc = etree.parse(StringIO( '<?xml version="1.0" standalone="true"?><root/>')) root = doc.getroot() or root = etree.fromstring( '<?xml version="1.0" standalone="true"?><root/>')
I added that header with etree.tostring(root, encoding='iso-8859-1') but can i add a flag with standalone value?
Not currently. Please file a wishlist bug in lxml's bug tracker. I think a flag on the _ElementTree class's docinfo property would work here.
what instruction is for create flags in a node?
This is not about changing nodes, but about changing documents features. Stefan

Hi, Ovnicraft wrote:
i created an xml now i want to make standalone declaration in my structure, how i can do it?
There isn't currently a way to set the flag programmatically, but you can just parse in the declaration like this: doc = etree.fromstring( '<?xml version="1.0" standalone="true"?><root/>') root = doc.getroot() root[:] = your_content_elements Stefan

Ovnicraft wrote:
Sorry, make that doc = etree.parse(StringIO( '<?xml version="1.0" standalone="true"?><root/>')) root = doc.getroot() or root = etree.fromstring( '<?xml version="1.0" standalone="true"?><root/>')
I added that header with etree.tostring(root, encoding='iso-8859-1') but can i add a flag with standalone value?
Not currently. Please file a wishlist bug in lxml's bug tracker. I think a flag on the _ElementTree class's docinfo property would work here.
what instruction is for create flags in a node?
This is not about changing nodes, but about changing documents features. Stefan
participants (2)
-
Ovnicraft
-
Stefan Behnel