[lxml-dev] Setting default namespace
Fabien
xphuture at gmail.com
Fri Feb 15 21:06:47 CET 2008
Hello,
I've a document with a namespace of the root element of my document
and when I display an element .tag, I get it with the namespace. Also,
when I'm using xpath(), I need to use the namespaces={..}) parameters.
Is there a way to define a default namespace in order to manipulate
the document like if it hasn't namespace ?
>>> xml = """
... <root xmlns="http://www.example.com">
... <a />
... <b />
... </root>
... """
>>> tree = etree.fromstring(xml)
>>> print tree
<Element {http://www.example.com}root at b73e702c>
>>> for element in tree:
... print element.tag
...
{http://www.example.com}a
{http://www.example.com}b
Thanks in advance.
--
Fabien SCHWOB
_____________________________________________________________
Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).
More information about the lxml-dev
mailing list