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 
*prefix)

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

  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).

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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