LXML: can't register namespace

Andrew Z formisc at gmail.com
Wed Mar 7 23:16:19 EST 2018


help(etree.register_namespace)
Help on cython_function_or_method in module lxml.etree:
register_namespace(prefix, uri)
    Registers a namespace prefix that newly created Elements in that
    namespace will use.  The registry is global, and any existing
    mapping for either the given prefix or the namespace URI will be
    removed.


On Wed, Mar 7, 2018 at 8:55 AM, Andrew Z <formisc at gmail.com> wrote:

> Yes, if i give it any non empty tag - all goes well.
>
> All im trying to do is to extract a namespace ( i try to keep simple here.
> Just first one for now) and register it so i can save xml later on.
>
>
> On Mar 7, 2018 00:38, "Steven D'Aprano" <steve+comp.lang.python@
> pearwood.info> wrote:
>
>> On Tue, 06 Mar 2018 23:03:15 -0500, Andrew Z wrote:
>>
>> > Hello,
>> >  with 3.6 and latest greatest lxml:
>> >
>> > from lxml import etree
>> >
>> > tree = etree.parse('Sample.xml')
>> > etree.register_namespace('','http://www.example.com')
>>
>> > it seems to not be happy with the empty tag . But i'm not sure why and
>> > how to go about it.
>>
>> Have you tried using something other than the empty string?
>>
>> In the interactive interpreter, what does
>>
>> help(etree.register_namespace)
>>
>> say?
>>
>>
>>
>> --
>> Steve
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>



More information about the Python-list mailing list