Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2589

Re: XML header with lxml

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail
From Chroma Key <chroma@key.invalid>
Newsgroups comp.lang.python
Subject Re: XML header with lxml
Date Mon, 4 Apr 2011 21:49:19 +0200
Organization Aioe.org NNTP Server
Lines 15
Message-ID <ind7bs$o4g$1@speranza.aioe.org> (permalink)
References <mailman.10.1301936101.9059.python-list@python.org>
NNTP-Posting-Host nsMplSW59Rm267QOeLHLbA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Unison/2.1.1
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2589

Show key headers only | View raw


On 2011-04-04 18:54:40 +0200, Jabba Laci said:

> I want to construct an XML file with lxml but I don't find how to add
> the '<?xml version="1.0"?>' header.
> 
> from lxml import etree as ET
> 
> html = ET.Element("html")
> print ET.tostring(html)

Add the "xml_declaration=True" as an argument of etree.tostring().

-- 
C-K

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

XML header with lxml Jabba Laci <jabba.laci@gmail.com> - 2011-04-04 12:54 -0400
  Re: XML header with lxml Chroma Key <chroma@key.invalid> - 2011-04-04 21:49 +0200
    Re: XML header with lxml Stefan Behnel <stefan_ml@behnel.de> - 2011-04-05 10:17 +0200

csiph-web