Perl duplicates xml tags : I'm a beginner in Perl (and in programming) and I have some problems with a script. I have tried by several ways to do what I want but there was always problems. So I want to start from scratch (again...) but I'm running out of ideas !

I need a script that will duplicate XML tags on an XML file, and add attributes to some of them. I know it could be easier with an XSLT but I need the script to ask if it has to duplicate tags or not, for each tag matched.

Here is a small and simple example of what I start with :

    <?xml version="1.0" encoding="UTF-8"?>
    <article>
        <section>
            <title>title</title>
            <para>text</para>
            <mediaobject>
                <imageobject>
                    <imagedata fileref="filename.png" format="PNG"/>    
                </imageobject>
            </mediaobject>
            <para>text</para>
        </section>
    </article>
...and what I want after passing the script :

    <?xml version="1.0" encoding="UTF-8"?>
    <article>
        <section>
            <title>title</title>
            <para>text</para>
            <mediaobject>
                <imageobject arch="html;fo;fo-print">
                    <imagedata fileref="filename.png" format="PNG"/>    
                </imageobject>
                <imageobject arch="screen">
                    <imagedata fileref="filename.png" format="PNG" width="100%"/>    
                </imageobject>
            </mediaobject>
        </section>
    </article>
For each image tag encounter (that correspond to the group : `<imageobject><imagedata fileref="filename.png" format="PNG"/></imageobject>`), I need the script to ask me if this group of tags have to be duplicate or not. If yes, it is duplicate and attributes @arch and @width are added.  If not, the script ask for the next group of tag matched.

Which parser can I use ? XML::LibXML ? If yes, how does it work ?

The XML files has to be external of the script and it would be nice if I could apply the script to several files.

I hope it is clear... If anyone has an idea how I can do this, or advices, it could help me a lot !
Thanks in advance.