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">

Where as I would suspect:

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

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



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
<> and
related thread.


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