Copy a word and insert a line: N times

I tried to meet my requirement using a topic in JS on this forum

I have a piece of XML code ( from SVG )

<symbol
      
    junk
       class="bi bi-currency-pound"
   junk

>
     
 <path
a lot of maths
         id="path1872-3" />

    </symbol>

I am trying to copy the value of ‘class’ and insert <title id=currency-pound>currency-pound</title> above the class as in

<symbol
      
    junk
      <title id=currency-pound>currency-pound</title>

       class="bi bi-currency-pound"
   junk

>
     
 <path
a lot of maths
         id="path1872-3" />

    </symbol>

While I can do this manually, each one of this is an icon and there are 1000+ entries like this. It would be nice to know how to automate this process using Python. I have Python 3.8.5 and Pycharm installed and have some basic understanding of Python.

But to begin with, I am not sure how to read the symbol file ( which is SVG, but I can save it as XML or text file ) and then let Python script make the changes.

Any help in this will be great. Thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.