[lxml-dev] xml:space and xml:lang problem

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Wed Feb 22 17:59:15 CET 2006


Scott Haeger wrote:
> Problem occurs: Note the xml namespace in the output.
> 
> from lxml import etree
> import sys
> intree = etree.parse("test.xml")
> outroot = etree.Element("root")
> doc = intree.getiterator()
> for el in doc:
>     newel = el
>     outroot.append (newel)
> outtree = etree.ElementTree(outroot)
> outtree.write(sys.stdout)
> 
> Test file:
> 
> <?xml version="1.0"?>
> <svg
>     xmlns:svg="http://www.w3.org/2000/svg <http://www.w3.org/2000/svg>"
>     xmlns:xml=" http://www.w3.org/XML/1998/namespace">
> <a id="first" xml:space="default"></a>
> </svg>

My system:
Python  - 2.4.2
lxml    - from scoder2 branch and current SVN
libxml2 - 2.6.23

My output for the above script:
<root><svg xmlns:svg="http://www.w3.org/2000/svg ">
</svg><a id="first" xml:space="default"/>
</root>

I do not see a problem here. Maybe you are using an outdated version of libxml2?

Stefan


More information about the lxml-dev mailing list