Re: [xml] Sorting/Building sorted DOM tree

On Sat, Nov 16, 2002 at 02:32:14PM -0700, Steve Williams wrote:

Is there any way to sort an xml document so that it conforms to a given 
schema? ( assuming it is correct and has all the relevant nodes).

I am getting a random stream of data that I am using to build an xml 
document.  It is being built correctly now, but I need to actually 
"order" the data because the input stream is not necessarily in the 
correct order.
Needs to end up being

The one way I figure to do it is to actually insert the nodes into the 
appropriate linked list in the correct order as I build the DOM model in 

My brain hurts, I know I am not going to explain this well.

Basically, I need the functionality of xmlNewChild, but rather than 
inserting the new node at the END of the parent children list, I need to 
insert it in a specific spot.

  wrong idea, xmlNewChild *create* a node, you want to *move* it.
Walk the Invoice children list and use xmlAddNextSibling() 

list by manually changing prev, current, and potentially the 
parent->last  pointer (as xmlNewChild does).

  that's another way, but this can be done cleanly with the API.
Walking the list reads the structure, but you use the API to change it.


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]