LXML: can't register namespace

Andrew Z formisc at gmail.com
Tue Mar 6 23:03:15 EST 2018


Hello,
 with 3.6 and latest greatest lxml:

from lxml import etree

tree = etree.parse('Sample.xml')
etree.register_namespace('','http://www.example.com')

causes:
Traceback (most recent call last):
  File "/home/az/Work/flask/tutorial_1/src/xml_oper.py", line 16, in
<module>
    etree.register_namespace('','http://www.example.com')
  File "src/lxml/etree.pyx", line 203, in lxml.etree.register_namespace
(src/lxml/etree.c:11705)
  File "src/lxml/apihelpers.pxi", line 1631, in lxml.etree._tagValidOrRaise
(src/lxml/etree.c:35382)
ValueError: Invalid tag name ''

partial Sample.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Applications xmlns="http://www.example.com">
 <Application>
  <Customer email="janed at acme.com" external_id="ABCDZ2002"
md_status_nonpro="true" type="INDIVIDUAL" prefix="jadoe">

<cut here>

it seems to not be happy with the empty tag .
But i'm not sure why and how to go about it.

thank you
AZ



More information about the Python-list mailing list