Re: [xml] Extracting multiple XML fragments of the same type

On Fri, Aug 23, 2002 at 12:27:36PM +0200, Holger Rauch wrote:
OK, but don't the API docs on xmlDocCopyNode() read

Do a copy of the node to a given document.


Following your suggestion, do I have to use something like

doc = xmlNewDoc( "1.0" );
newNode = xmlDocCopyNode( curNode, doc, 1 );
doc->children = newNode;

in my code?

   Use the tree API !

(curNode points to a fragment of the original document, and 
I would like to create a new document containing only the fragment
curNode currently points to.) But I must admit that I don't
understand the meaning (and the necessity) of the doc parameter in
xmlDocCopyNode(). To me, it seems it is only used for making


to a new document (at least that's the impression I got from debugging my 
  You still don't want to understand that *every node* pertaining to a
document have a doc pointer pointing to that document. That childre
are linked as children and last, that they also are linked together
as a double list.
  doing doc->children breaks all of this !
  not passing doc to xmlDocCopyNode() forces to update the doc links 
     on all the nodes when repluging the fragment.
   If you have trouble with the tree structures, then it's better you limit
yourself to manipulate the tree with the API which tries to keep it consistent.

Please enlighten me on this issue. Thanks a lot!

  The problem here is that *I can't scale my time* !
  I cannot explain over and over again the same things, it would bring my
development speed to a halt. So please try to reuse the existing documentation,
agreed it's not perfect nor complete but I take patches !


Daniel Veillard      | Red Hat Network
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]