|Don't ask to ask, just ask|
Manipulate xml with libxmlby Anonymous Monk
|on Jun 07, 2005 at 17:06 UTC||Need Help??|
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I think that my brain has reached its capacity and I need help for a algorithm I am not able to implement. It is very important!
I have to parse a xml file (model.xml). In this file, there is a nested repetitive motif. For instance,
I mean in each element (<aaa></aaa>, <bbb></bbb>) I can find the same structure recursivly, without number limitation. (the name of <aaa></aaa> etc. element is random, only the <fixe> has a constant name).
I use DOM with the XML::LibXML API. The goal of my script is to remove the <fixe></fixe> elements and according to parameters (A number od dupplication and name of element) to dupplicate the node. for example, name = eee and number = 4, the xml would become.
I have done this script which remove the element "fixe"
for the duplication, I have tried to use the addSibling function with a foreach but I got an error, I try also the cloneNode and insertBefore function but no way...
Any help would be very appreciated.