Re: [lxml-dev] newb: How to create a simple xml file?

March 30, 2007
5 a.m.
Ram Peters wrote:
I needed to know how to create xml headers, using lxml like this: <?xml version="1.0" encoding="UTF-8"?> ?
Hmm, why? By specification, there is no difference between this <?xml version="1.0" encoding="UTF-8"?> <weatherNow xmlns="http://example.com/weatherNow/"> <temperature>57</temperature> <pressure>29.97</pressure> <pressureChange>rising</pressureChange> </weatherNow> and this <weatherNow xmlns="http://example.com/weatherNow/"> <temperature>57</temperature> <pressure>29.97</pressure> <pressureChange>rising</pressureChange> </weatherNow> However, if you really need to output the header, pass the "xml_declaration=True" keyword argument to tostring() or write(). Hope it helps, Stefan
6541
Age (days ago)
6541
Last active (days ago)
0 comments
1 participants
participants (1)
-
Stefan Behnel