I am trying to recreate a batch of (360 files) SVGs because they were given a <clip
path>
tag that points to a <rect>
tag inside of <defs>
tags. It also created a <polygon>
element with a fill attribute. I am trying to delete the <clipPath>
, <defs>
and <polygon>
tags, but keep the <rect>
tag and give it the polygon's fill attribute.
I tried to do this in regex, but it was too complicated and didn't seem like it could be done very well.
I tried to dabble with doing it in java with an xml parser class, but I could not figure out how to access the attributes (I tried using the .getAttributes()
method, but it would not pull the attributes for the element).
Here is some of my sample code:
<defs>
<rect id="SVGID_1_" y="0" width="1023.88" height="100.08"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" display="none" overflow="visible"/>
</clipPath>
<polygon clip-path="url(#SVGID_2_)" fill="#E81E25" points="-0.12,0 -0.12,100.08 1023.88,100.08 1023.88,0"/>
This is what it should be:
<rect fill="#E81E25" width="1023.88" height="100.08"/>
How can I batch convert 360 files to be formatted like I want above with the <rect>
tag?