Re: LXML: can't register namespace

2018-03-09 Thread Andrew Z
Stefan, thank you for the link. That explains the line of thinking of the package designer(s). I also looked@ beautifulsoup and found it to work better with my old brains. On Fri, Mar 9, 2018 at 9:46 AM, Stefan Behnel wrote: > Peter Otten schrieb am 09.03.2018 um 14:11: >

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Peter Otten schrieb am 09.03.2018 um 14:11: > Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxml import etree >>> >>> tree = etree.parse('Sample.xml') >>> etree.register_namespace('','http://www.example.com') >>

Re: LXML: can't register namespace

2018-03-09 Thread Peter Otten
Stefan Behnel wrote: > Andrew Z schrieb am 07.03.2018 um 05:03: >> Hello, >> with 3.6 and latest greatest lxml: >> >> from lxml import etree >> >> tree = etree.parse('Sample.xml') >> etree.register_namespace('','http://www.example.com') > > The default namespace prefix is spelled None

Re: LXML: can't register namespace

2018-03-09 Thread Steven D'Aprano
On Fri, 09 Mar 2018 13:08:10 +0100, Stefan Behnel wrote: >> Is there a good reason not to support "" as the empty prefix? > > Well, the "empty prefix" is not an "empty" prefix, it's *no* prefix. The > result is not ":tag" instead of "prefix:tag", the result is "tag". That makes sense, thanks.

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Steven D'Aprano schrieb am 09.03.2018 um 12:41: > On Fri, 09 Mar 2018 10:22:23 +0100, Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxml import etree >>> >>> tree = etree.parse('Sample.xml') >>>

Re: LXML: can't register namespace

2018-03-09 Thread Steven D'Aprano
On Fri, 09 Mar 2018 10:22:23 +0100, Stefan Behnel wrote: > Andrew Z schrieb am 07.03.2018 um 05:03: >> Hello, >> with 3.6 and latest greatest lxml: >> >> from lxml import etree >> >> tree = etree.parse('Sample.xml') >> etree.register_namespace('','http://www.example.com') > > The default

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Andrew Z schrieb am 07.03.2018 um 05:03: > Hello, > with 3.6 and latest greatest lxml: > > from lxml import etree > > tree = etree.parse('Sample.xml') > etree.register_namespace('','http://www.example.com') The default namespace prefix is spelled None (because there is no prefix for it) and

Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
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

Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
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.pyt...@pearwood.info> wrote: > On Tue,

Re: LXML: can't register namespace

2018-03-06 Thread Steven D'Aprano
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 >