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 }
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 }
func (a PArray) MarshalXML(e *xml.Encoder, start xml.StartElement) error { start.Name = xml.Name{Local: "array"} e.EncodeToken(start) for _, el := range a { el.(xml.Marshaler).MarshalXML(e, start) } e.EncodeToken(start.End()) return nil }
func (d PDict) MarshalXML(e *xml.Encoder, start xml.StartElement) error { start.Name = xml.Name{Local: "dict"} e.EncodeToken(start) for k, v := range d { e.EncodeElement(k, xml.StartElement{Name: xml.Name{Local: "key"}}) v.MarshalXML(e, start) } e.EncodeToken(start.End()) return nil }
//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 }
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() }
// 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 }
// 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) }
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 }
// 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 }
// 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) }