-1
xml.dom.minidom을 사용하여이 XML을 편집하려고하지만 변경해야하는 값을 얻는 방법을 모르겠습니다. 나는 "customGetCapabilities"값을 "true"로 변경하고 "pathToCustomGetCapabilitiesFiles"에 URL을 지정하고 싶습니다 여기에서Python으로 XML 편집
나는,
<SVCExtension xsi:type="typens:SVCExtension">
<Enabled>true</Enabled>
<Info xsi:type="typens:PropertySet">
<PropertyArray xsi:type="typens:ArrayOfPropertySetProperty">
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>WebEnabled</Key>
<Value xsi:type="xs:string">true</Value>
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>WebCapabilities</Key>
<Value xsi:type="xs:string">GetCapabilities,GetMap,GetFeatureInfo,GetStyles,GetLegendGraphic,GetSchemaExtension</Value>
</PropertySetProperty>
</PropertyArray>
</Info>
<Props xsi:type="typens:PropertySet">
<PropertyArray xsi:type="typens:ArrayOfPropertySetProperty">
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>onlineResource</Key>
<Value xsi:type="xs:string">*censored url*</Value>
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>customGetCapabilities</Key>
<Value xsi:type="xs:string">false</Value>
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>pathToCustomGetCapabilitiesFiles</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>pathToCustomSLDFile</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>inheritLayerNames</Key>
<Value xsi:type="xs:string">false</Value>
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>name</Key>
<Value xsi:type="xs:string">WMS</Value>
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>title</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>abstract</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>keyword</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactPerson</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactPosition</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactOrganization</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>address</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>addressType</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>city</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>stateOrProvince</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>postCode</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>country</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactVoiceTelephone</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactFacsimileTelephone</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>contactElectronicMailAddress</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>fees</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
<PropertySetProperty xsi:type="typens:PropertySetProperty">
<Key>accessConstraints</Key>
<Value xsi:type="xs:string" />
</PropertySetProperty>
</PropertyArray>
</Props>
<TypeName>WMSServer</TypeName>
</SVCExtension>
이제() doc.getElementsByTagName하여이 덩어리에 액세스 할 수 있습니다.
다른 사람들이 저 값으로 분석하는 방법을 가르쳐 주시겠습니까? 고맙습니다.
특정 질문이 필요합니다. ElementTree를 사용하여 XML 파싱을 살펴보십시오. 사용하기 쉽고 문서화가 잘되어 있으며 풍부한 기능을 제공합니다. –
ElementTree를 사용하여 살펴 보았습니다. 그러나 XML을 다시 작성하는 데는 많은 문제가 추가됩니다. XML을 다시 작성하기 전에 네임 스페이스를 제거하는 것처럼 보입니다. 그러지 않으려 고합니다. – calk93
ElementTree (또는 특히 lxml.etree)가 부정확하게 왕복 이동하는 경우, 이는 놀랍습니다 (후자의 경우 매우 놀랍습니다). 그리고 별도의 질문을위한 근거. –