Re: [xml] Set Default Namespace



Hi Martin,

Thanks for the replay and the note about setting the namespace for the
root node. This was another porblem I was having.

I tried you suggestion even before posting this question but a small
test program yields the following results:

<?xml version="1.0" encoding="UTF-8"?>
<site xmlns:="default">
  <node>element</node>
</site>

Where as I would suspect:

<?xml version="1.0" encoding="UTF-8"?>
<site xmlns="default">
  <node>element</node>
</site>

I'm rather new to XML but I believe the proper declaration of the
default name space should be without the double-colon, right?

Regards,

Niels


On Sun, Aug 24, 2008 at 5:16 PM, Martin (gzlist) <gzlist googlemail com> wrote:
On 22/08/2008, Niels Van Hoef <niels vanhoef gmail com> wrote:

 When generating an XML document I want to set a default namespace as
 recommended on the namespaces page of the xmlsoft website. The
 function "xmlNewNs" only allows me to set a namespace with a prefix
 but not change/insert a default namespace.

I may be missing the point here, but just pass NULL as the prefix to
xmlNewNs? Also note, for the root element, you need to create the
element, then the ns, then use xmlSetNs, see
<http://mail.gnome.org/archives/xml/2008-June/msg00069.html> and
related thread.

Martin




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