Re: [xml] xmlCopyNode & xmlDocCopyNode

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

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

  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 Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine
Sep 17-18 2001 Brussels Red Hat TechWorld

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