[xml] how to build dom tree with ns decls


I want to this document:
<?xml version="1.0"?>
<t1:test xmlns:t1="ns1.test">something iside</t1:test>

but the result which I keep getting is:

<?xml version="1.0"?>
<t1:test>something iside</t1:test>

(the ns decl is missing). I used the code at the end.
Can someone tell me what should I do to have there the namespace declaration
Isn't this a problem of the  xmlDocDump function, to produce namespace
declaration attrs. where they are necessary ?

Thanks in advance

here the code:

------  t1.c  -------
#include <stdio.h>
#include <libxml/tree.h>

int main(int argc, char **argv)
 xmlChar* buff;
 int ln;

 xmlDocPtr doc;
 xmlNsPtr ns;
 xmlNodePtr root;
 xmlNodePtr el;

 doc = xmlNewDoc(NULL);
 root = xmlNewDocNode(doc, NULL, "root", NULL);
 xmlAddChild((xmlNodePtr) doc, root);

 ns = xmlNewNs((xmlNodePtr)doc, "ns1.test", "t1");
 el = xmlNewDocNode(doc, ns, "t1:test", "something iside");

 xmlAddChild(root, el);

 xmlDocDumpFormatMemory(doc, &buff, &ln, 1);


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