當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Encoder.EncodeElement方法代碼示例

本文整理匯總了Golang中encoding/xml.Encoder.EncodeElement方法的典型用法代碼示例。如果您正苦於以下問題:Golang Encoder.EncodeElement方法的具體用法?Golang Encoder.EncodeElement怎麽用?Golang Encoder.EncodeElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在encoding/xml.Encoder的用法示例。


在下文中一共展示了Encoder.EncodeElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: MarshalXML

func (bagc BiddableAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"BiddableAdGroupCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&bagc.AdGroupId, xml.StartElement{Name: xml.Name{"", "adGroupId"}})
	criterionMarshalXML(bagc.Criterion, e)

	if bagc.UserStatus != "" {
		e.EncodeElement(&bagc.UserStatus, xml.StartElement{Name: xml.Name{"", "userStatus"}})
	}
	if bagc.DestinationUrl != "" {
		e.EncodeElement(&bagc.DestinationUrl, xml.StartElement{Name: xml.Name{"", "destinationUrl"}})
	}
	e.EncodeElement(&bagc.BiddingStrategyConfiguration, xml.StartElement{Name: xml.Name{"", "biddingStrategyConfiguration"}})
	if bagc.BidModifier != 0 {
		e.EncodeElement(&bagc.BidModifier, xml.StartElement{Name: xml.Name{"", "bidModifier"}})
	}
	e.EncodeToken(start.End())
	return nil
}
開發者ID:Nyarum,項目名稱:gads,代碼行數:25,代碼來源:biddable_ad_group_criterion.go

示例2: MarshalXML

// MarshalXML implementation on JobErrorDateTime to skip "zero" time values
func (jdt JobErrorDateTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if jdt.IsZero() {
		return nil
	}
	e.EncodeElement(jdt.Time, start)
	return nil
}
開發者ID:NYTimes,項目名稱:encoding-wrapper,代碼行數:8,代碼來源:job.go

示例3: MarshalXML

func (n CharData) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	return e.EncodeElement(struct {
		S string `xml:",innerxml"`
	}{
		S: "<![CDATA[" + string(n) + "]]>",
	}, start)
}
開發者ID:StephaneTy-Pro,項目名稱:Pickles2TesLink,代碼行數:7,代碼來源:Pickles2TestLink.go

示例4: MarshalXML

// MarshalXML реализует интерфейс xml.Marshaler для объекта NullDate
// сериализация происходит с учётом шаблона, заданного в свойстве Layout
func (d NullDate) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error {
	if !d.Valid {
		return encoder.EncodeElement(nil, start)
	}
	d.fixLayout()
	return encoder.EncodeElement(d.String(), start)
}
開發者ID:mihteh,項目名稱:types,代碼行數:9,代碼來源:datetime.go

示例5: MarshalXML

func (n NominalType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if n == Nominal {
		return e.EncodeElement("NOMINAL", start)
	} else {
		return e.EncodeElement("CALCULATED", start)
	}
}
開發者ID:GeoNet,項目名稱:delta,代碼行數:7,代碼來源:nominal_type.go

示例6: MarshalXML

// MarshalXML marshals NullInts greater than zero to XML. Otherwise nothing is
// marshaled.
func (n NullInt) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if n.Valid {
		e.EncodeElement(n.Int, start)
	}

	return nil
}
開發者ID:fubotv,項目名稱:go-recurly,代碼行數:9,代碼來源:type_null_int.go

示例7: MarshalXML

// MarshalXML marshals times into their proper format. Otherwise nothing is
// marshaled. All times are sent in UTC.
func (t NullTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if t.Time != nil {
		e.EncodeElement(t.String(), start)
	}

	return nil
}
開發者ID:fubotv,項目名稱:go-recurly,代碼行數:9,代碼來源:type_null_time.go

示例8: MarshalXML

func (f ApproximationType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {

	if f < approximationTypeEnd {
		return e.EncodeElement(approximationTypeLookup[f], start)
	}

	return fmt.Errorf("invalid approximation type: %d", f)
}
開發者ID:GeoNet,項目名稱:delta,代碼行數:8,代碼來源:approximation_type.go

示例9: MarshalXML

func (b *boolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	val := "False"
	if *b {
		val = "True"
	}
	e.EncodeElement(val, start)
	return nil
}
開發者ID:ironmig,項目名稱:gokeepasslib,代碼行數:8,代碼來源:bool_wrapper.go

示例10: MarshalXML

func (d Datum) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if d.Time != nil {
		formattedDate := d.Time.Format(xmlDateFormat)
		e.EncodeElement(formattedDate, start)
	}

	return nil
}
開發者ID:peteraba,項目名稱:invoice-export,代碼行數:8,代碼來源:behavior.go

示例11: MarshalXML

// MarshalXML marshals NullBools to XML. Otherwise nothing is
// marshaled.
func (u UnitAmount) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if u.USD > 0 || u.EUR > 0 {
		v := (uaAlias)(u)
		e.EncodeElement(v, start)
	}

	return nil
}
開發者ID:blacklightcms,項目名稱:go-recurly,代碼行數:10,代碼來源:type_unit_amount.go

示例12: MarshalXML

func (a CacheBehaviors) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedCacheBehaviors{
		Quantity: len(a),
		Items:    []CacheBehavior(a),
	}

	return e.EncodeElement(enc, start)
}
開發者ID:abacusadvertising,項目名稱:Stout,代碼行數:8,代碼來源:cloudfront.go

示例13: MarshalXML

func (a AlfredOutput) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Local: "items"}
	e.EncodeToken(start)
	for _, item := range a {
		e.EncodeElement(item, xml.StartElement{Name: xml.Name{Local: "item"}})
	}
	e.EncodeToken(start.End())
	return nil
}
開發者ID:v-yarotsky,項目名稱:dawg,代碼行數:9,代碼來源:alfred.go

示例14: writeData

// writeData base64-encodes val.
func writeData(e *xml.Encoder, val []byte) error {
	var encoded bytes.Buffer
	encoder := base64.NewEncoder(base64.StdEncoding, &encoded)
	// Just writing to a buffer, can't fail.
	encoder.Write(val)
	encoder.Close()

	return e.EncodeElement(encoded.String(), dataStartElement)
}
開發者ID:zach-klippenstein,項目名稱:goplist,代碼行數:10,代碼來源:base_encoder.go

示例15: MarshalXML

// MarshalXML marshals the netconfInfo map as an array of XML
// <error-info> sub-elements
func (info netconfInfo) MarshalXML(e *xml.Encoder, se xml.StartElement) error {
	for key, value := range info {
		name := string(key)
		elem := xml.StartElement{Name: xml.Name{Local: name}}
		if err := e.EncodeElement(value, elem); err != nil {
			return err
		}
	}
	return nil
}
開發者ID:tsuna,項目名稱:goarista,代碼行數:12,代碼來源:errs.go


注:本文中的encoding/xml.Encoder.EncodeElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。