Re: [xml] Exchanging same XML fragment in multiple XML documents



On Tue, Nov 05, 2002 at 12:09:46PM +0100, Holger Rauch wrote:
How can I search for a node having a certain name *without* making a
particular assumption on the document structure? I know there are the
"children", "parent", "next", and "prev" links, but using these I would
have to assume that

a) my document structure remains always the same or
b) change my code each time my document structure changes

  Strange, I'm 100% sure I can write completely generic tree traversing
algorithms with just "children", "parent", "next".

So, what's the way around this problem?

  Opening a basic book on data structure algorithms ? 
  Alternately use the XPath module and search for "//your_node_name[1]"

I am aware that there's a function named
xmlParseBalancedChunkMemory() that can be used to turn the textual
representation of the new fragment into a node list (xmlNodePtr). However,
the first parameter of this function is an xmlDocPtr, so it seems I would
actually have to use this function inside the loop so that
xmlParseBalancedChunkMemory() always "knows" about the current
document. However, this seems inefficient to me since it shouldn't be

  It's a complex operation, it has limitations (there is NO semantic defined
in the XML specifications about parsing a fragment of a document, this does
not exist, don't try it).

document the fragment should be part of in the loop (for performance
reasons)? If so, how can I do this?

(I was looking at both tree.c and parser.c and the HTML documentation, I

  You apparently missed the xmlCopyNode() and related operations.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
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]