[xml] Namespaces! Agh!



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?

-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   for all your tapsell ferrier needs



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]