How to modify the XML file using Python?
<p>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.</p>

<pre><code>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
</code></pre>

<p>You should probably read through the <a href="http://docs.geoserver.org/latest/en/user/styling/sld/cookbook/index.html" rel="nofollow">SLD Cook book</a> 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 <a href="http://docs.geoserver.org/latest/en/user/rest/api/styles.html" rel="nofollow"><code>PUT</code> request</a> to place the file back on the server.</p>

python xml django geoserver