Modifying XML (svg) with PHP

Job ID: 35567933

Budget: €30 – €250 EUR

XML file (svg-image) needs to be modified using PHP in following way. Please also see the example svg-files. Including the original file and one that I have modified manually to match the desired outcome.

- All id values such as id=“text1_x5F_text2_x5F_text3” needs to be converted into ids and classes. “_x5F_” is the divider here. First string remains as id and rest are converted into classes. For example in above case, the outcome should be id=“text1” class=“text2 text3 oldclasses”. So in case the element had original classes, those need to be retained as well.


- After above modifications, all elements in svg that have class “line” should be duplicated on top (after in code) of original element. Those new elements should have new ID and additional class, so that for element #highway1.line.tap, the element above would be #highway1-top.line.top. Notice that the class “tap” is not carried to this new element.


- Similarly, all elements in svg that have both classes “line” and “tap” should be duplicated below (before in code) original element and original element should loose the “tap” class. Those new elements should have new ID and additional class, so that for element #highway1.line.tap, element below should be #highway1-hit.line.tap.hit


- Comment at top should be removed: <!— Generator*****—>


- The end result, when page is loaded/refreshed needs to be a new modified svg-file saved right next to original. Original svg path can be hardcoded.




- Php-code must be commented and version 8.x is ok.
Related categories: PHP XML