[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] Namespaces! Agh!
- From: Daniel Veillard <veillard redhat com>
- To: Nic James Ferrier <nferrier tapsellferrier co uk>
- Cc: libxml <xml gnome org>
- Subject: Re: [xml] Namespaces! Agh!
- Date: Sat, 1 Jul 2006 17:18:12 -0400
On Sat, Jul 01, 2006 at 08:34:38PM +0100, Nic James Ferrier wrote:
> Ok. Here's something I don't understand about namespaces (libxml2 in
> python):
>
> dom = libxml2.newDoc("1.0")
>
> root = dom.newChild(None, "root", None)
> ns = root.newNs("http://www.tfnet.co.uk/somenamespace", "ns")
> root.setNs(ns)
>
> node = root.newChild(ns, "element", None)
> node.newChild(None, "child", None)
>
>
> And the output is:
>
> <root xmlns:ns="http://www.tfnet.co.uk/somenamespace">
> <ns:element>
> <ns:child/>
> </ns:element>
> </root>
>
> And the bit I don't understand is why the child element is marked with
> the ns namespace.
>
>
> Can anyone explain this?
Well basically xmlNewChild() create a new node in the parent namespace if
no namespace is provided. Try to setNs(None) on the resulting node. Okay the
API is a bit weird, but changng it now is likely to break stuff...
Daniel
--
Daniel Veillard | Red Hat http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]