How to edit the path of an SVG using the code

In the path of an SVG file <path id =“12121”, fill=“FF0000”…>. How to get the attributes inside the path and edit any specific attribute. For example, if i want to change the color of that path for any selected ids. how do i write a code for that?
Thank you

I use xml and svg work similar I think.

slImg = loadXML("images.xml");
    slImgs = slImg.getChildren("diapo");
    for (int i=0; i<slImgs.length; i++) {
        XML[] imgs;
        imgs = slImgs[i].getChildren("path");
        for (int j=0; j<imgs.length; j++) {
            int x = imgs[j].getInt("x");//here put your attribute