本文整理汇总了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
}
示例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
}
示例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
}
示例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()
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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)
}