How to modify the XML file using Python?
Question: Actually I have got the XML string and parse the string to get the attributes
from it. Now I want my XML file to change, viewing the attributes. Like I want
to change the color of the stroke. Is there any way? How I will change and
then again save the file.

    
    
    import requests
    from xml.dom import minidom
    
    response = requests.get('http://localhost:8080/geoserver/rest/styles/pakistan.sld',
                            auth=('admin', 'geoserver'))
    fo=open("/home/adeel/Desktop/untitled1/yes.xml", "wb")
    fo.write(response.text)
    fo.close()
    
    xmldoc = minidom.parse('yes.xml')
    itemlist = xmldoc.getElementsByTagName('CssParameter')
    print "Len : ", len(itemlist)
    #print "Attribute Name : ", \
    itemlist[0].attributes['name'].value
    print "Text : ", itemlist[0].firstChild.nodeValue
    
    for s in itemlist :
        print "Attribute Name : ", s.attributes['name'].value
        print "Text : ", s.firstChild.nodeValue
    


Answer: You should probably read through the [SLD Cook
book](http://docs.geoserver.org/latest/en/user/styling/sld/cookbook/index.html)
to get hints on how to change things like the colour of the lines in your SLD.
Once you've changed it you need to make a [`PUT`
request](http://docs.geoserver.org/latest/en/user/rest/api/styles.html) to
place the file back on the server.

