Example #1
0
File: xml.go Project: Neeke/beego
func (xmls *XMLConfig) Parse(filename string) (ConfigContainer, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()
	x := &XMLConfigContainer{
		data: make(map[string]interface{}),
	}
	content, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, err
	}
	d, err := x2j.DocToMap(string(content))
	if err != nil {
		return nil, err
	}
	x.data = d["config"].(map[string]interface{})
	return x, nil
}
Example #2
0
File: xml.go Project: chaws/beego
// Parse returns a ConfigContainer with parsed xml config map.
func (xc *Config) Parse(filename string) (config.Configer, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	x := &ConfigContainer{data: make(map[string]interface{})}
	content, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, err
	}

	d, err := x2j.DocToMap(string(content))
	if err != nil {
		return nil, err
	}

	x.data = config.ExpandValueEnvForMap(d["config"].(map[string]interface{}))
	return x, nil
}