Re: [xml] root node with namespace

On Sat, Jun 21, 2008 at 05:12:59PM +0000, dhk wrote:
How is a root node created with a namespace?  It seem that to make the 
root node I'd need to have a namespace to use with xmlNewNode() and to 
make a namespace I would need to call xmlNewNs() which requires a node 
as indicated in the following two functions.

xmlNodePtr xmlNewNode(xmlNsPtr ns, const xmlChar *name)

xmlNsPtr xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar 

Which call comes first and how do you create your first node with a 

  As Martin code shows up:
  Create first the node without the namespace, 
  Then create a namespace definition on that node
  Assign the node to the namespace by doing node->ns = ns;

You can double check this work by serializing the node (assuming the
namespace has a prefix).


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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