[xml] Namespaces



Hi all,

I was just wondering how to use namespaces with libxml2.
I do something like:

document = xmlNewDoc((const xmlChar *) "1.0");
root = xmlNewDocNode(document, NULL, (const xmlChar *) "IDMEF-Message", NULL);
idmefNS=xmlNewNs(root, (const xmlChar *) "http://iana.org/idmef";,
                  (const xmlChar *) "idmef");
xmlDocSetRootElement(document, root);
...

Afterwards I am using "xmlNodeDumpOutput" to print the
XML. I expected that I would get prefixed names when
printing some xml documents, something like:

 <idmef:IDMEF-Message xmlns:idmef="http://iana.org/idmef";>
    <idmef:Alert messageid="1234567890">
    ...

But I just get:

<IDMEF-Message xmlns:idmef="http://iana.org/idmef";>
  <Alert messageid="1234567890">
  ...

Do I have to add the prefixes by myself? Or did I miss
some libxml2 magic commands? :-)

Thanks for any help,

Olaf

-- 
Dipl.Inform. Olaf Gellert                  PRESECURE (R)
Senior Researcher,                       Consulting GmbH
Phone: (+49) 0700 / PRESECURE           og pre-secure de

                        A daily view on Internet Attacks
                        https://www.ecsirt.net/sensornet




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