话部多说,xml格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<conf>
<nova>192.168.0.1</nova>
<glance>192.168.0.2</glance>
<keystone>192.168.0.3</keystone>
</conf>
conf文件如下:
[service_ip_list]
keystone = X.X.X.X
nova = X
glance = X
需要提取xml中的属性和值替换掉conf中的对应的配置,转换程序是用python写的
#-*-coding:utf-8-*-
from xml.dom import minidom
doc = minidom.parse("conf.xml")
conf_elements=doc.getElementsByTagName("conf")[0]
nova=conf_elements.getElementsByTagName("nova")[0]
#print nova.nodeName, nova.childNodes[0].nodeValue
glance=conf_elements.getElementsByTagName("glance")[0]
#print glance.nodeName, glance.childNodes[0].nodeValue
keystone=conf_elements