当前位置: 首页>>代码示例>>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;未经允许,请勿转载。