2
実際には、私はXML文字列を取得し、それから属性を取得するために文字列を解析しています。 XMLファイルを変更して属性を表示します。ストロークの色を変えたいのですが。何か方法はありますか?どのようにファイルを変更し、再度保存するのか。Pythonを使用してXMLファイルを変更するには?
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
私はすでにそれを把握しています。とにかくあなたの助けを感謝します –