The tag you want to be looking for is 'TypeName'.
you can access it like this:
import xml.dom.minidom as dom
def feature_server_toggle(doc, status):
type_names = doc.getElementsByTagName('TypeName')
for type_name in type_names:
if type_name.firstChild.data == "FeatureServer" and status.lower() == 'on':
type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "true"
if type_name.firstChild.data == "FeatureServer" and status.lower() == 'off':
type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "false"
sddraft = <path/to/sddraft>
output = <path/to/output>
doc = dom.parse(sddraft)
with open(output, 'w+') as xml:
feature_server_toggle(doc, 'on')
doc.writexml(xml)
Or you could alter the function to allow it to enable or disable any capability like so:
import xml.dom.minidom as dom
def capability_toggle(doc, server_type, status):
type_names = doc.getElementsByTagName('TypeName')
for type_name in type_names:
if type_name.firstChild.data == "{}".format(server_type) and status.lower() == 'on':
type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "true"
if type_name.firstChild.data == "{}".format(server_type) and status.lower() == 'off':
type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "false"
sddraft = <path/to/sddraft>
output = <path/to/output>
doc = dom.parse(sddraft)
with open(output, 'w+') as xml:
capability_toggle(doc, 'FeatureServer', 'on')
capability_toggle(doc, 'KmlServer', 'off')
doc.writexml(xml)
Here is a list of valid values to use for server_type:
- ‘KmlServer’
- ‘FeatureServer’
- ‘MapServer’
- ‘WCSServer’
- ‘WMSServer’
- ‘WFSServer’
- ‘SchematicsServer’
- ‘MobileServer’
- ‘NAServer’