Re: [xml] xmlCopyNode & xmlDocCopyNode



On Mon, Jun 18, 2001 at 10:41:23AM +0200, Oliver Feige wrote:
Hallo,

when I use xmlCopyNode or xmlDocCopyNode then the new node has no
Attributes!! Only when I do it recursive!!

node = xmlCopyNode(cur, 0); // No Attributes in node

is this a Bug?? I think a Attribute carried by a Node should be copied
to!!

  Well, this is not a bug. In the DOM model attributes are nodes too.
So a recursive copy includes them while a non-recursive copy doesn't.
Since it's a relatively old API I don't feel like changing the semantic
now for example I think libxslt relies on this behaviour. The same
applies to namespace declarations on a node. You can add them at your
level by using:

    if (node->nsDef != NULL)
        ret->nsDef = xmlCopyNamespaceList(node->nsDef);
    if (node->properties != NULL)
        ret->properties = xmlCopyPropList(ret, node->properties);

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Sep 17-18 2001 Brussels Red Hat TechWorld http://www.redhat-techworld.com




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