// UnmarshalXML handles unmarshalling an OOList element from an XML string
558688
func (o *OOList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	for {
		tok, err := nextNonWhitespaceToken(d)
		if err != nil {
			return err
		} else if end, ok := tok.(xml.EndElement); ok && end.Name.Local == start.Name.Local {
			// If we found the end of our starting element, we're done parsing
			return nil
		} else if startElement, ok := tok.(xml.StartElement); ok {
			switch startElement.Name.Local {
			case "OOBUYDEBT":
				var oo OOBuyDebt
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOBUYMF":
				var oo OOBuyMF
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOBUYOPT":
				var oo OOBuyOpt
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOBUYOTHER":
				var oo OOBuyOther
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOBUYSTOCK":
				var oo OOBuyStock
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOSELLDEBT":
				var oo OOSellDebt
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOSELLMF":
				var oo OOSellMF
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOSELLOPT":
				var oo OOSellOpt
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOSELLOTHER":
				var oo OOSellOther
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "OOSELLSTOCK":
				var oo OOSellStock
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			case "SWITCHMF":
				var oo OOSwitchMF
				if err := d.DecodeElement(&oo, &startElement); err != nil {
					return err
				}
				*o = append(*o, OpenOrder(oo))
			default:
				return errors.New("Invalid OOList child tag: " + startElement.Name.Local)
			}
		} else {
			return errors.New("Didn't find an opening element")
		}
	}
}
1071529
func (ruleList *FilterRuleList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	// Make subtype to avoid recursive UnmarshalXML().
	type filterRuleList FilterRuleList
	rules := filterRuleList{}
	if err := d.DecodeElement(&rules, &start); err != nil {
		return err
	}

	// FilterRuleList must have only one prefix and/or suffix.
	nameSet := set.NewStringSet()
	for _, rule := range rules.Rules {
		if nameSet.Contains(rule.Name) {
			if rule.Name == "prefix" {
				return &ErrFilterNamePrefix{}
			}

			return &ErrFilterNameSuffix{}
		}

		nameSet.Add(rule.Name)
	}

	*ruleList = FilterRuleList(rules)
	return nil
}
760112
func (ob *Boolean) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if *ob {
		return e.EncodeElement("Y", start)
	}
	return e.EncodeElement("N", start)
}
1036251
func (conf *Config) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	// Make subtype to avoid recursive UnmarshalXML().
	type config Config
	parsedConfig := config{}
	if err := d.DecodeElement(&parsedConfig, &start); err != nil {
		return err
	}

	// Empty queue list means user wants to delete the notification configuration.
	if len(parsedConfig.QueueList) > 0 {
		for i, q1 := range parsedConfig.QueueList[:len(parsedConfig.QueueList)-1] {
			for _, q2 := range parsedConfig.QueueList[i+1:] {
				if reflect.DeepEqual(q1, q2) {
					return &ErrDuplicateQueueConfiguration{q1}
				}
			}
		}
	}

	if len(parsedConfig.LambdaList) > 0 || len(parsedConfig.TopicList) > 0 {
		return &ErrUnsupportedConfiguration{}
	}

	*conf = Config(parsedConfig)

	return nil
}
189786
func (s *Session) UnmarshalXML(data interface{}) (err error) {
	bufrw := bytes.NewBuffer(nil)
	s.Stdout = bufrw
	if err = s.Run(); err != nil {
		return
	}
	return xml.NewDecoder(bufrw).Decode(data)
}
1276149
func (s *Socket) ReadXML(v interface{}) (err error) {
	_, r, err := s.NextReader()
	if err != nil {
		return err
	}
	return xml.NewDecoder(r).Decode(v)
}
1145437
func (z *Dec) UnmarshalText(data []byte) error {
	_, ok := z.SetString(string(data))
	if !ok {
		return fmt.Errorf("invalid inf.Dec")
	}
	return nil
}
1270944
func Xml(v interface{}, rootTag ...string) ([]byte, error) {
	if reflect.TypeOf(v).Kind() == reflect.Struct {
		return xml.Marshal(v)
	}

	var err error
	s := new(string)
	p := new(pretty)

	var rt string
	if len(rootTag) == 1 {
		rt = rootTag[0]
	} else {
		rt = DefaultRootTag
	}

	var ss string
	var b []byte
	switch v.(type) {
	case []interface{}:
		ss = "<" + rt + ">"
		for _, vv := range v.([]interface{}) {
			switch vv.(type) {
			case map[string]interface{}:
				m := vv.(map[string]interface{})
				if len(m) == 1 {
					for tag, val := range m {
						err = mapToXmlIndent(false, s, tag, val, p)
					}
				} else {
					err = mapToXmlIndent(false, s, "element", vv, p)
				}
			default:
				err = mapToXmlIndent(false, s, "element", vv, p)
			}
			if err != nil {
				break
			}
		}
		ss += *s + "</" + rt + ">"
		b = []byte(ss)
	case map[string]interface{}:
		b, err = anyxml(v.(map[string]interface{}), rootTag...)
	case []map[string]interface{}:
		for _, vv := range v.([]map[string]interface{}) {
			b, err = anyxml(vv, rootTag...)
			ss += string(b)
			if err != nil {
				break
			}
		}
		b = []byte(ss)
	default:
		err = mapToXmlIndent(false, s, rt, v, p)
		b = []byte(*s)
	}

	return b, err
}
481273
func (ce *CoordinatesElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if err := e.EncodeToken(coordinatesStartElement); err != nil {
		return err
	}
	for i, c := range ce.coordinates {
		s := ""
		if i != 0 {
			s = " "
		}
		s += strconv.FormatFloat(c.Lon, 'f', -1, 64) + "," + strconv.FormatFloat(c.Lat, 'f', -1, 64)
		if c.Alt != 0 {
			s += "," + strconv.FormatFloat(c.Alt, 'f', -1, 64)
		}
		if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil {
			return err
		}
	}
	return e.EncodeToken(coordinatesEndElement)
}
9046
func (p *Prometheus) UnmarshalTOML(data interface{}) error {
	dataOK, ok := data.(map[string]interface{})
	if !ok {
		return errors.New("bad urls for prometheus input plugin")
	}
	urls, ok := dataOK["urls"].([]interface{})
	if !ok {
		return errors.New("urls is not an array for prometheus input plugin")
	}
	for _, url := range urls {
		p.URLs = append(p.URLs, url.(string))
	}
	return nil
}
158165
func (level *Level) UnmarshalText(text []byte) error {
	l, err := ParseLevel(string(text))
	if err != nil {
		return err
	}

	*level = Level(l)

	return nil
}
794292
func (i *Int) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	var value string

	err := d.DecodeElement(&value, &start)
	if err != nil {
		return err
	}

	value = strings.TrimSpace(value)

	i2, err := strconv.ParseInt(value, 10, 64)
	if err != nil {
		return err
	}

	*i = Int(i2)
	return nil
}
259019
func ServeXml(w http.ResponseWriter, v interface{}) {
	content, err := xml.Marshal(v)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.Header().Set("Content-Length", strconv.Itoa(len(content)))
	w.Header().Set("Content-Type", "text/xml; charset=utf-8")
	w.Write(content)
}
1190932
func (cae *CoordinatesArrayElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if err := e.EncodeToken(coordinatesStartElement); err != nil {
		return err
	}
	for i, c := range cae.coordinates {
		s := ""
		if i != 0 {
			s = " "
		}
		s += strconv.FormatFloat(c[0], 'f', -1, 64) + "," + strconv.FormatFloat(c[1], 'f', -1, 64)
		if len(c) > 2 && c[2] != 0 {
			s += "," + strconv.FormatFloat(c[2], 'f', -1, 64)
		}
		if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil {
			return err
		}
	}
	return e.EncodeToken(coordinatesEndElement)
}
350204
func (c *Consumer) PostXML(url string, body string, token *AccessToken) (resp *http.Response, err error) {
	return c.makeAuthorizedRequest("POST", url, LOC_XML, body, nil, token)
}
403470
func (msl *MessageSetList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	for {
		var msgset MessageSet
		tok, err := nextNonWhitespaceToken(d)
		if err != nil {
			return err
		} else if end, ok := tok.(xml.EndElement); ok && end.Name.Local == start.Name.Local {
			// If we found the end of our starting element, we're done parsing
			return nil
		} else if _, ok := tok.(xml.StartElement); ok {
			// Found starting tag for <xxxMSGSET>. Get the next one (xxxMSGSETVn) and decode that struct
			tok, err := nextNonWhitespaceToken(d)
			if err != nil {
				return err
			} else if versionStart, ok := tok.(xml.StartElement); ok {
				if err := d.DecodeElement(&msgset, &versionStart); err != nil {
					return err
				}
			} else {
				return errors.New("Invalid MSGSETLIST formatting")
			}
			msgset.Name = msgset.XMLName.Local

			// Eat ending tags for <xxxMSGSET>
			tok, err = nextNonWhitespaceToken(d)
			if err != nil {
				return err
			} else if _, ok := tok.(xml.EndElement); !ok {
				return errors.New("Invalid MSGSETLIST formatting")
			}
		} else {
			return errors.New("MSGSETLIST didn't find an opening xxxMSGSETVn element")
		}
		*msl = MessageSetList(append(*(*[]MessageSet)(msl), msgset))
	}
}
307169
func (c *Context) BindXML(obj interface{}) error {
	return c.MustBindWith(obj, binding.XML)
}