[libxml++] Adding child with certain order




Hi.

I´m processing a xml file in which children should be added in certain order.

For example:

These should not be valid:
<root>
    <book>
        <chapter></chapter>
        <chapter></chapter>
        <preface></preface>
    </book>
</root>

as <preface> should be the first child of <book>. The fact is I get this xml file already written and only the <chapter>s nodes are there. Only during runtime I can get information relative to preface, when I add it with book_node->add_child("preface"), making it exist as on the example above (as the last child).

How could I manage to insert <preface> before <chapter>s? Is there a special method for inserting a child at a certain position inside its root node tree?

Thanks in advance. I really urge for an effective solution.

Regards,
Arthur

PS.: the node names here are fictitious for simplifying purposes.


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