[xml] how to add namespace-less node in python
- From: Hannu Krosing <hannu tm ee>
- To: xml gnome org
- Subject: [xml] how to add namespace-less node in python
- Date: Sat, 20 Dec 2003 18:50:12 +0200
Hallo
I need to add a node that has no namespace prefix while building xml doc
in python (for my home-made SOAP server/client lib).
I know that such a tree is possible, as it is correctly generated by
libxml2.parseFile :
d = libxml2.parseFile('nstest.xml')
print d.serialize(None,1)
<?xml version="1.0"?>
<doc xmlns:a="http://www.krosing.net/testns">
<a:para>
<title/>
</a:para>
</doc>
But I am unable to make similar tree programmatically:
doc = libxml2.newDoc("1.0")
root = doc.newChild(None, "doc", None)
docns = root.newNs("http://www.krosing.net/testns","a")
para = root.newChild(docns, "para", None)
title = para.newChild(None, "title", None)
print doc.serialize(None,1)
<?xml version="1.0"?>
<doc xmlns:a="http://www.krosing.net/testns">
<a:para>
<a:title/>
</a:para>
</doc>
I want to get <title/> and not <a:title/> .
What am I doing wrong ?
----------------------
Hannu
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]