// OutputXML returns the text that including tags name.
8950
func (n *Node) OutputXML(self bool) string {
	var buf bytes.Buffer
	if self {
		outputXML(&buf, n)
	} else {
		for n := n.FirstChild; n != nil; n = n.NextSibling {
			outputXML(&buf, n)
		}
	}

	return buf.String()
}
853389
func (o OutputFormats) Get(name string) *OutputFormat {
	for _, f := range o {
		if strings.EqualFold(f.Format.Name, name) {
			return &f
		}
	}
	return nil
}
1319
func (pb PackageBuilder) PackageXml() []byte {
	p := createPackage()

	for _, metaType := range pb.Metadata {
		p.Types = append(p.Types, metaType)
	}

	byteXml, _ := xml.MarshalIndent(p, "", "    ")
	byteXml = append([]byte(xml.Header), byteXml...)
	//if err := ioutil.WriteFile("mypackage.xml", byteXml, 0644); err != nil {
	//ErrorAndExit(err.Error())
	//}
	return byteXml
}
77841
func (r *Response) WriteHeaderAndXml(status int, value interface{}) error {
	return writeXML(r, status, MIME_XML, value)
}
535550
func BuildXML(params interface{}, e *xml.Encoder) error {
	return buildXML(params, e, false)
}
727192
func ReadXml(r *http.Request, v interface{}) error {
	body, err := ioutil.ReadAll(r.Body)
	r.Body.Close()
	if err != nil {
		return err
	}
	return xml.Unmarshal(body, v)
}
1262092
func (s *Socket) SendXML(data interface{}) (err error) {
	w, err := s.NextWriter(websocket.TextMessage)
	if err != nil {
		return err
	}
	if data != nil {
		xml.NewEncoder(w).Encode(data)
	}
	return w.Close()
}
1089937
func (n *Network) OutputBlockPath(channelName string) string {
	return filepath.Join(n.RootDir, fmt.Sprintf("%s_block.pb", channelName))
}
948520
func (c *Controller) RenderXML(o interface{}) Result {
	c.setStatusIfNil(http.StatusOK)

	return RenderXMLResult{o}
}
1348033
func (r *Render) XML(w io.Writer, status int, v interface{}) error {
	head := Head{
		ContentType: r.opt.XMLContentType + r.compiledCharset,
		Status:      status,
	}

	x := XML{
		Head:   head,
		Indent: r.opt.IndentXML,
		Prefix: r.opt.PrefixXML,
	}

	return r.Render(w, x, v)
}
1063167
func (ss *simpleSource) OutputMap() map[string]interface{} {
	var jsonMap map[string]interface{}
	if err := json.Unmarshal(ss.rawData, &jsonMap); err != nil {
		fmt.Println(err)
		return nil
	}
	return jsonMap
}
1255878
func (filter *ClientFilter) OutputFilter(data []byte, context rpc.Context) []byte {
	if context.GetBool("jsonrpc") {
		request := make(map[string]interface{})
		if filter.Version == "1.1" {
			request["version"] = "1.1"
		} else if filter.Version == "2.0" {
			request["jsonrpc"] = "2.0"
		}
		reader := io.NewReader(data, false)
		reader.JSONCompatible = true
		tag, _ := reader.ReadByte()
		if tag == io.TagCall {
			request["method"] = reader.ReadString()
			tag, _ = reader.ReadByte()
			if tag == io.TagList {
				reader.Reset()
				count := reader.ReadCount()
				params := make([]interface{}, count)
				for i := 0; i < count; i++ {
					reader.Unserialize(&params[i])
				}
				request["params"] = params
			}
		}
		request["id"] = atomic.AddInt32(&filter.id, 1)
		data, _ = json.Marshal(request)
	}
	return data
}
315967
func (b *HttpRequest) ToXml(v interface{}) error {
	data, err := b.Bytes()
	if err != nil {
		return err
	}
	return xml.Unmarshal(data, v)
}
751270
func (filter ServiceFilter) OutputFilter(data []byte, context rpc.Context) []byte {
	responses, ok := context.GetInterface("jsonrpc").([]map[string]interface{})
	if ok && responses != nil {
		reader := io.NewReader(data, false)
		reader.JSONCompatible = true
		tag, _ := reader.ReadByte()
		for _, response := range responses {
			if tag == io.TagResult {
				reader.Reset()
				var result interface{}
				reader.Unserialize(&result)
				response["result"] = result
				tag, _ = reader.ReadByte()
			} else if tag == io.TagError {
				reader.Reset()
				err := make(map[string]interface{})
				err["code"] = -1
				message := reader.ReadString()
				err["message"] = message
				tag, _ = reader.ReadByte()
				response["error"] = err
			}
			if tag == io.TagEnd {
				break
			}
		}
		if len(responses) == 1 {
			data, _ = json.Marshal(responses[0])
		} else {
			data, _ = json.Marshal(responses)
		}
	}
	return data
}
1237448
func outputHelper(info, namespace string, singleNamespace bool) string {
	if singleNamespace {
		return info
	}
	return fmt.Sprintf("<%s %s>", namespace, info)
}
723648
func buildOutput(name string, tbl *ast.Table) (*models.OutputConfig, error) {
	filter, err := buildFilter(tbl)
	if err != nil {
		return nil, err
	}
	oc := &models.OutputConfig{
		Name:   name,
		Filter: filter,
	}

	// TODO
	// Outputs don't support FieldDrop/FieldPass, so set to NameDrop/NamePass
	if len(oc.Filter.FieldDrop) > 0 {
		oc.Filter.NameDrop = oc.Filter.FieldDrop
	}
	if len(oc.Filter.FieldPass) > 0 {
		oc.Filter.NamePass = oc.Filter.FieldPass
	}

	if node, ok := tbl.Fields["flush_interval"]; ok {
		if kv, ok := node.(*ast.KeyValue); ok {
			if str, ok := kv.Value.(*ast.String); ok {
				dur, err := time.ParseDuration(str.Value)
				if err != nil {
					return nil, err
				}

				oc.FlushInterval = dur
			}
		}
	}

	if node, ok := tbl.Fields["metric_buffer_limit"]; ok {
		if kv, ok := node.(*ast.KeyValue); ok {
			if integer, ok := kv.Value.(*ast.Integer); ok {
				v, err := integer.Int()
				if err != nil {
					return nil, err
				}
				oc.MetricBufferLimit = int(v)
			}
		}
	}

	if node, ok := tbl.Fields["metric_batch_size"]; ok {
		if kv, ok := node.(*ast.KeyValue); ok {
			if integer, ok := kv.Value.(*ast.Integer); ok {
				v, err := integer.Int()
				if err != nil {
					return nil, err
				}
				oc.MetricBatchSize = int(v)
			}
		}
	}

	delete(tbl.Fields, "flush_interval")
	delete(tbl.Fields, "metric_buffer_limit")
	delete(tbl.Fields, "metric_batch_size")

	return oc, nil
}
1241459
func (logs *Logs) InitFromXMLString(str string) error {
	cfg, err := config.ParseXMLString(str)
	if err != nil {
		return err
	}
	return logs.Init(cfg)
}