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


Golang StartElement.Name方法代碼示例

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


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

示例1: MarshalXML

func (p PList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Local: "plist"}
	start.Attr = []xml.Attr{xml.Attr{Name: xml.Name{Local: "version"}, Value: "1.0"}}
	e.EncodeToken(start)
	PDict(p).MarshalXML(e, xml.StartElement{})
	e.EncodeToken(start.End())
	return nil
}
開發者ID:v-yarotsky,項目名稱:dawg,代碼行數:8,代碼來源:plist.go

示例2: 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

示例3: MarshalXML

//Magic that sets downloadFormat automaticaly
func (c *ReportDefinition) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	c.DownloadFormat = DOWNLOAD_FORMAT_XML

	type Alias ReportDefinition

	start.Name = xml.Name{
		"", "reportDefinition",
	}

	e.EncodeElement((*Alias)(c), start)
	return nil
}
開發者ID:Nyarum,項目名稱:gads,代碼行數:13,代碼來源:report_utils.go

示例4: writeOpen

func (s *serverStream) writeOpen() error {
	var start xml.StartElement
	start.Name = xml.Name{Local: "stream:stream", Space: "jabber:client"}
	start.Attr = append(start.Attr,
		xml.Attr{Name: xml.Name{Local: "xmlns:stream"}, Value: "http://etherx.jabber.org/streams"},
		xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"},
		xml.Attr{Name: xml.Name{Local: "from"}, Value: s.from},
		xml.Attr{Name: xml.Name{Local: "version"}, Value: s.version},
	)
	if err := s.streamEncoder.EncodeToken(start); err != nil {
		return err
	}

	// xml.Encoder doesn't flush until it generated end tag
	// so we flush here to make it send stream's open tag
	return s.streamEncoder.Flush()
}
開發者ID:tuhuayuan,項目名稱:goxmpp,代碼行數:17,代碼來源:stream.go

示例5: MarshalXML

// Allows type H to be used with xml.Marshal
func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{"", "map"}
	if err := e.EncodeToken(start); err != nil {
		return err
	}
	for key, value := range h {
		elem := xml.StartElement{
			xml.Name{"", key},
			[]xml.Attr{},
		}
		if err := e.EncodeElement(value, elem); err != nil {
			return err
		}
	}
	if err := e.EncodeToken(xml.EndElement{start.Name}); err != nil {
		return err
	}
	return nil
}
開發者ID:heymanchen,項目名稱:gin,代碼行數:20,代碼來源:gin.go

示例6: MarshalXML

// MarshalXML implements the XML Marshaler interface
func (s *Show) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Space: "", Local: "tvshow"}

	nfo := &showFields{
		Title:     s.Title,
		ShowTitle: s.Title,
		Rating:    s.Rating,
		Plot:      s.Plot,
		URL:       s.URL,
		TvdbID:    s.TvdbID,
		ImdbID:    s.ImdbID,
		Year:      s.Year,
	}

	if s.FirstAired != nil {
		nfo.Premiered = s.FirstAired.Format("2006-01-02")
	}

	return e.EncodeElement(nfo, start)
}
開發者ID:odwrtw,項目名稱:polochon,代碼行數:21,代碼來源:show.go

示例7: MarshalXML

func (t *Tag) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = t.Name
	start.Attr = t.Attr
	e.EncodeToken(start)
	for _, v := range t.Children {
		switch v.(type) {
		case *Tag:
			child := v.(*Tag)
			if err := e.Encode(child); err != nil {
				return err
			}
		case xml.CharData:
			e.EncodeToken(v.(xml.CharData))
		case xml.Comment:
			e.EncodeToken(v.(xml.Comment))
		}
	}
	e.EncodeToken(start.End())
	return nil
}
開發者ID:nobonobo,項目名稱:gomobileapp,代碼行數:20,代碼來源:xmlutil.go

示例8: MarshalXML

// Allows type H to be used with xml.Marshal
func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{
		Space: "",
		Local: "map",
	}
	if err := e.EncodeToken(start); err != nil {
		return err
	}
	for key, value := range h {
		elem := xml.StartElement{
			Name: xml.Name{Space: "", Local: key},
			Attr: []xml.Attr{},
		}
		if err := e.EncodeElement(value, elem); err != nil {
			return err
		}
	}
	if err := e.EncodeToken(xml.EndElement{Name: start.Name}); err != nil {
		return err
	}
	return nil
}
開發者ID:BTBurke,項目名稱:remailer,代碼行數:23,代碼來源:utils.go

示例9: MarshalXML

// MarshalXML implements the XML Marshaler interface
func (e *Episode) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Space: "", Local: "episodedetails"}

	nfo := &episodeFields{
		Title:         e.Title,
		ShowTitle:     e.ShowTitle,
		Season:        e.Season,
		Episode:       e.Episode,
		TvdbID:        e.TvdbID,
		Aired:         e.Aired,
		Premiered:     e.Aired,
		Plot:          e.Plot,
		Runtime:       e.Runtime,
		Thumb:         e.Thumb,
		Rating:        e.Rating,
		ShowImdbID:    e.ShowImdbID,
		ShowTvdbID:    e.ShowTvdbID,
		EpisodeImdbID: e.EpisodeImdbID,
	}

	return enc.EncodeElement(nfo, start)
}
開發者ID:odwrtw,項目名稱:polochon,代碼行數:23,代碼來源:episode.go


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