Documentation
¶
Index ¶
- Constants
- Variables
- func FormatDate(s, layout string) string
- func Parse(r io.Reader) (Type, Feed, error)
- func ParseDate(ds string) (t time.Time, err error)
- type AtomCategory
- type AtomCommonAttributes
- type AtomContent
- type AtomDateConstruct
- type AtomEmailAddress
- type AtomEntry
- type AtomFeed
- type AtomGenerator
- type AtomIcon
- type AtomId
- type AtomLanguageTag
- type AtomLink
- type AtomLogo
- type AtomMediaType
- type AtomNCName
- type AtomPersonConstruct
- type AtomSource
- type AtomTextConstruct
- type AtomUri
- type AtomXhtmlDiv
- type Feed
- type JSONAttachments
- type JSONAuthor
- type JSONFeed
- type JSONItem
- type RssAuthor
- type RssCategory
- type RssChannel
- type RssContent
- type RssEnclosure
- type RssFeed
- type RssGuid
- type RssImage
- type RssItem
- type RssSkipDays
- type RssSkipHours
- type RssSource
- type RssTextInput
- type Type
- type UndefinedContent
- type XmlGeneric
- type XmlText
Constants ¶
const ( // MimeAtom https://datatracker.ietf.org/doc/html/rfc4287#section-7 MimeAtom = "application/atom+xml" MimeAtomFallback = "application/xml" )
const ( // MimeJSON https://www.jsonfeed.org/version/1.1/#suggestions-for-publishers-a-name-suggestions-for-publishers-a MimeJSON = "application/feed+json" MimeJSONFallback = "application/json" )
const ( // MimeRss https://www.rssboard.org/rss-mime-type-application.txt MimeRss = "application/rss+xml" MimeRssFallback = "application/xml" )
Variables ¶
var ( ErrXsdStringNotMatchingPattern = errors.New("xsd:string not matching pattern") ErrXsdStringNotMatchingMinLength = errors.New("xsd:string not matching minLength") )
Functions ¶
func FormatDate ¶
Types ¶
type AtomCategory ¶
type AtomCategory struct { AtomCommonAttributes Term string `xml:"term,attr"` Scheme AtomUri `xml:"scheme,attr,omitempty"` Label string `xml:"label,attr,omitempty"` UndefinedContent []UndefinedContent `xml:",any,omitempty"` }
AtomCategory The "atom:category" element conveys information about a category
associated with an entry or feed. This specification assigns no meaning to the content (if any) of this element. atomCategory = element atom:category { AtomCommonAttributes, attribute term { text }, attribute scheme { AtomUri }?, attribute label { text }?, undefinedContent }
type AtomCommonAttributes ¶
type AtomCommonAttributes struct { Base AtomUri `xml:"base,attr,omitempty"` Language AtomLanguageTag `xml:"lang,attr,omitempty"` // https://github.com/golang/go/issues/3633#issuecomment-328678522 UndefinedAttribute []xml.Attr `xml:",any,attr,omitempty"` }
AtomCommonAttributes Common attributes
AtomCommonAttributes = attribute xml:base { AtomUri }?, attribute xml:lang { AtomLanguageTag }?, undefinedAttribute*
type AtomContent ¶
type AtomContent struct { AtomCommonAttributes Type string `xml:"type,attr,omitempty"` Src *AtomUri `xml:"src,attr,omitempty"` XmlText Div *AtomXhtmlDiv `xml:"div,omitempty"` }
AtomContent atom:content
atomInlineTextContent = element atom:content { AtomCommonAttributes, attribute type { "text" | "html" }?, (text)* } atomInlineXHTMLContent = element atom:content { AtomCommonAttributes, attribute type { "xhtml" }, AtomXhtmlDiv } atomInlineOtherContent = element atom:content { AtomCommonAttributes, attribute type { AtomMediaType }?, (text|anyElement)* } atomOutOfLineContent = element atom:content { AtomCommonAttributes, attribute type { AtomMediaType }?, attribute src { AtomUri }, empty } AtomContent = atomInlineTextContent | atomInlineXHTMLContent | atomInlineOtherContent | atomOutOfLineContent
func (*AtomContent) MarshalXML ¶
func (a *AtomContent) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*AtomContent) String ¶
func (a *AtomContent) String() string
type AtomDateConstruct ¶
type AtomDateConstruct struct { AtomCommonAttributes // TODO xsd:dateTime DateTime string `xml:",chardata"` }
AtomDateConstruct Date Construct
AtomDateConstruct = AtomCommonAttributes, xsd:dateTime
type AtomEmailAddress ¶
type AtomEmailAddress string
AtomEmailAddress Whatever an email address is, it contains at least one @
AtomEmailAddress = xsd:string { pattern = ".+@.+" }
func (*AtomEmailAddress) UnmarshalXML ¶
func (a *AtomEmailAddress) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type AtomEntry ¶
type AtomEntry struct { AtomCommonAttributes Authors []*AtomPersonConstruct `xml:"author"` Categories []*AtomCategory `xml:"category,omitempty"` Content *AtomContent `xml:"content,omitempty"` Contributors []*AtomPersonConstruct `xml:"contributor,omitempty"` ID *AtomId `xml:"id,omitempty"` Links []*AtomLink `xml:"link,omitempty"` Published *AtomDateConstruct `xml:"published,omitempty"` Rights *AtomTextConstruct `xml:"rights,omitempty"` Source *AtomSource `xml:"source,omitempty"` Summary *AtomTextConstruct `xml:"summary,omitempty"` Title *AtomTextConstruct `xml:"title,omitempty"` Updated *AtomDateConstruct `xml:"updated,omitempty"` ExtensionElement []XmlGeneric `xml:",any,omitempty"` }
AtomEntry atom:entry
AtomEntry = [ s:rule [ context = "atom:entry" s:assert [ test = "atom:link[@rel='alternate'] " ~ "or atom:link[not(@rel)] " ~ "or atom:content" "An atom:entry must have at least one atom:link element " ~ "with a rel attribute of 'alternate' " ~ "or an atom:content." ] ] s:rule [ context = "atom:entry" s:assert [ test = "atom:author or " ~ "../atom:author or atom:source/atom:author" "An atom:entry must have an atom:author " ~ "if its feed does not." ] ] ] element atom:entry { AtomCommonAttributes, (AtomAuthor* & AtomCategory* & AtomContent? & atomContributor* & AtomId & AtomLink* & AtomPublished? & atomRights? & AtomSource? & atomSummary? & atomTitle & atomUpdated & ExtensionElement*) }
type AtomFeed ¶
type AtomFeed struct { XMLName xml.Name AtomCommonAttributes Authors []*AtomPersonConstruct `xml:"author,omitempty"` Categories []*AtomCategory `xml:"category,omitempty"` Contributors []*AtomPersonConstruct `xml:"contributor,omitempty"` Generator *AtomGenerator `xml:"generator,omitempty"` Icon *AtomIcon `xml:"icon,omitempty"` ID AtomId `xml:"id"` Links []*AtomLink `xml:"link,omitempty"` Logo *AtomLogo `xml:"logo,omitempty"` Rights *AtomTextConstruct `xml:"rights,omitempty"` Subtitle *AtomTextConstruct `xml:"subtitle,omitempty"` Title *AtomTextConstruct `xml:"title,omitempty"` Updated *AtomDateConstruct `xml:"updated,omitempty"` ExtensionElement []XmlGeneric `xml:",any"` Entries []*AtomEntry `xml:"entry,omitempty"` }
AtomFeed atom:feed
atomFeed = [ s:rule [ context = "atom:feed" s:assert [ test = "atom:author or not(atom:entry[not(atom:author)])" "An atom:feed must have an atom:author unless all " ~ "of its atom:entry children have an atom:author." ] ] ] element atom:feed { AtomCommonAttributes, (atomAuthor* & AtomCategory* & atomContributor* & AtomGenerator? & AtomIcon? & AtomId & AtomLink* & AtomLogo? & atomRights? & atomSubtitle? & atomTitle & atomUpdated & ExtensionElement*), AtomEntry* }
type AtomGenerator ¶
type AtomGenerator struct { AtomCommonAttributes URI AtomUri `xml:"uri,attr,omitempty"` Version string `xml:"version,attr,omitempty"` Text string `xml:",chardata"` }
AtomGenerator The "atom:generator" element's content identifies the agent used to
generate a feed, for debugging and other purposes. AtomGenerator = element atom:generator { AtomCommonAttributes, attribute uri { AtomUri }?, attribute version { text }?, text }
type AtomIcon ¶
type AtomIcon struct { AtomCommonAttributes AtomUri `xml:",chardata"` }
AtomIcon atom:icon
AtomIcon = element atom:icon { AtomCommonAttributes, (AtomUri) }
type AtomId ¶
type AtomId struct { AtomCommonAttributes AtomUri `xml:",chardata"` }
AtomId atom:id
AtomId = element atom:id { AtomCommonAttributes, (AtomUri) }
type AtomLanguageTag ¶
type AtomLanguageTag string
AtomLanguageTag As defined in RFC 3066
AtomLanguageTag = xsd:string { pattern = "[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*" }
func (*AtomLanguageTag) UnmarshalXML ¶
func (a *AtomLanguageTag) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type AtomLink ¶
type AtomLink struct { AtomCommonAttributes Href AtomUri `xml:"href,attr"` // TODO rel { atomNCName | atomUri } Rel string `xml:"rel,attr,omitempty"` Type AtomMediaType `xml:"type,attr,omitempty"` Hreflang AtomLanguageTag `xml:"hreflang,attr,omitempty"` Title string `xml:"title,attr,omitempty"` Length string `xml:"length,attr,omitempty"` UndefinedContent []UndefinedContent `xml:",any"` }
AtomLink The "atom:link" element defines a reference from an entry or feed to
a Web resource. This specification assigns no meaning to the content (if any) of this element. AtomLink = element atom:link { AtomCommonAttributes, attribute href { AtomUri }, attribute rel { AtomNCName | AtomUri }?, attribute type { AtomMediaType }?, attribute hreflang { AtomLanguageTag }?, attribute title { text }?, attribute length { text }?, undefinedContent }
type AtomLogo ¶
type AtomLogo struct { AtomCommonAttributes AtomUri `xml:",chardata"` }
AtomLogo atom:logo
AtomLogo = element atom:logo { AtomCommonAttributes, (AtomUri) }
type AtomMediaType ¶
type AtomMediaType string
AtomMediaType Whatever a media type is, it contains at least one slash
AtomMediaType = xsd:string { pattern = ".+/.+" }
type AtomNCName ¶
type AtomNCName string
AtomNCName AtomNCName = xsd:string { minLength = "1" pattern = "[^:]*" }
func (*AtomNCName) UnmarshalXML ¶
func (a *AtomNCName) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type AtomPersonConstruct ¶
type AtomPersonConstruct struct { AtomCommonAttributes Name string `xml:"name,omitempty"` Uri AtomUri `xml:"uri,omitempty"` Email AtomEmailAddress `xml:"email,omitempty"` }
AtomPersonConstruct Person Construct
AtomPersonConstruct = AtomCommonAttributes, (element atom:name { text } & element atom:uri { AtomUri }? & element atom:email { AtomEmailAddress }? & ExtensionElement*)
type AtomSource ¶
type AtomSource struct { AtomCommonAttributes Authors []*AtomPersonConstruct `xml:"author"` Categories []*AtomCategory `xml:"category,omitempty"` Contributors []*AtomPersonConstruct `xml:"contributor,omitempty"` Generator *AtomGenerator `xml:"generator,omitempty"` Icon *AtomIcon `xml:"icon,omitempty"` ID AtomId `xml:"id"` Links []*AtomLink `xml:"link,omitempty"` Logo *AtomLogo `xml:"logo,omitempty"` Rights *AtomTextConstruct `xml:"rights,omitempty"` Subtitle *AtomTextConstruct `xml:"subtitle,omitempty"` Title *AtomTextConstruct `xml:"title"` Updated *AtomDateConstruct `xml:"updated,omitempty"` ExtensionElement []XmlGeneric `xml:",any,omitempty"` }
AtomSource atom:source
AtomSource = element atom:source { AtomCommonAttributes, (atomAuthor* & AtomCategory* & atomContributor* & AtomGenerator? & AtomIcon? & AtomId? & AtomLink* & AtomLogo? & atomRights? & atomSubtitle? & atomTitle? & atomUpdated? & ExtensionElement*) }
type AtomTextConstruct ¶
type AtomTextConstruct struct { AtomCommonAttributes Type string `xml:"type,attr,omitempty"` XmlText Div *AtomXhtmlDiv `xml:"div,omitempty"` }
AtomTextConstruct = AtomPlainTextConstruct | AtomXHTMLTextConstruct
func (*AtomTextConstruct) MarshalXML ¶
func (a *AtomTextConstruct) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*AtomTextConstruct) String ¶
func (a *AtomTextConstruct) String() string
type AtomUri ¶
type AtomUri string
AtomUri Unconstrained; it's not entirely clear how IRI fit into
xsd:anyURI so let's not try to constrain it here AtomUri = text
type AtomXhtmlDiv ¶
type AtomXhtmlDiv struct { UndefinedAttribute []xml.Attr `xml:",any,attr,omitempty"` // TODO text | anyXHTML XmlText }
AtomXhtmlDiv anyXHTML = element xhtml:* { (attribute * { text } | text | anyXHTML)* } xhtmlDiv = element xhtml:div { (attribute * { text } | text | anyXHTML)* }
type JSONAttachments ¶
type JSONAttachments struct { // URL url (required, string) specifies the location of the attachment. URL string `json:"url,omitempty"` // MimeType mime_type (required, string) specifies the type of the attachment, such as “audio/mpeg.” MimeType string `json:"mime_type,omitempty"` // Title title (optional, string) is a name for the attachment. Important: if there are multiple attachments, and two or more have the exact same title (when title is present), then they are considered as alternate representations of the same thing. In this way a podcaster, for instance, might provide an audio recording in different formats. Title string `json:"title,omitempty"` // SizeInBytes size_in_bytes (optional, number) specifies how large the file is. SizeInBytes uint64 `json:"size_in_bytes,omitempty"` // DurationInSeconds duration_in_seconds (optional, number) specifies how long it takes to listen to or watch, when played at normal speed. DurationInSeconds uint64 `json:"duration_in_seconds,omitempty"` }
JSONAttachments attachments (optional, array) lists related resources. Podcasts, for instance, would include an attachment that’s an audio or video file. Each attachment has several members:
type JSONAuthor ¶
type JSONAuthor struct { // Name name (optional, string) is the author’s name. Name string `json:"name,omitempty"` // URL url (optional, string) is the URL of a site owned by the author. It could be a blog, micro-blog, Twitter account, and so on. Ideally the linked-to page provides a way to contact the author, but that’s not required. The URL could be a mailto: link, though we suspect that will be rare. URL string `json:"url,omitempty"` // Avatar avatar (optional, string) is the URL for an image for the author. As with icon, it should be square and relatively large — such as 512 x 512 — and should use transparency where appropriate, since it may be rendered on a non-white background. Avatar string `json:"avatar,omitempty"` }
JSONAuthor author (optional, object) specifies the feed author. The author object has several members. These are all optional — but if you provide an author object, then at least one is required:
type JSONFeed ¶
type JSONFeed struct { // Version version (required, string) is the URL of the version of the format the feed uses. This should appear at the very top, though we recognize that not all JSON generators allow for ordering. Version string `json:"version,omitempty"` // Title title (required, string) is the name of the feed, which will often correspond to the name of the website (blog, for instance), though not necessarily. Title string `json:"title,omitempty"` // HomePageURL home_page_url (optional but strongly recommended, string) is the URL of the resource that the feed describes. This resource may or may not actually be a “home” page, but it should be an HTML page. If a feed is published on the public web, this should be considered as required. But it may not make sense in the case of a file created on a desktop computer, when that file is not shared or is shared only privately. HomePageURL string `json:"home_page_url,omitempty"` // FeedURL feed_url (optional but strongly recommended, string) is the URL of the feed, and serves as the unique identifier for the feed. As with home_page_url, this should be considered required for feeds on the public web. FeedURL string `json:"feed_url,omitempty"` // Description description (optional, string) provides more detail, beyond the title, on what the feed is about. A feed reader may display this text. Description string `json:"description,omitempty"` // UserComment user_comment (optional, string) is a description of the purpose of the feed. This is for the use of people looking at the raw JSON, and should be ignored by feed readers. UserComment string `json:"user_comment,omitempty"` // NextURL next_url (optional, string) is the URL of a feed that provides the next n items, where n is determined by the publisher. This allows for pagination, but with the expectation that reader software is not required to use it and probably won’t use it very often. next_url must not be the same as feed_url, and it must not be the same as a previous next_url (to avoid infinite loops). NextURL string `json:"next_url,omitempty"` // Icon icon (optional, string) is the URL of an image for the feed suitable to be used in a timeline, much the way an avatar might be used. It should be square and relatively large — such as 512 x 512 — so that it can be scaled-down and so that it can look good on retina displays. It should use transparency where appropriate, since it may be rendered on a non-white background. Icon string `json:"icon,omitempty"` // Favicon favicon (optional, string) is the URL of an image for the feed suitable to be used in a source list. It should be square and relatively small, but not smaller than 64 x 64 (so that it can look good on retina displays). As with icon, this image should use transparency where appropriate, since it may be rendered on a non-white background. Favicon string `json:"favicon,omitempty"` // Author author (optional, object) specifies the feed author. The author object has several members. These are all optional — but if you provide an author object, then at least one is required: Author *JSONAuthor `json:"author,omitempty"` // Expired expired (optional, boolean) says whether or not the feed is finished — that is, whether or not it will ever update again. A feed for a temporary event, such as an instance of the Olympics, could expire. If the value is true, then it’s expired. Any other value, or the absence of expired, means the feed may continue to update. Expired *bool `json:"expired,omitempty"` // Items is an array, and is required. An item includes: Items []*JSONItem `json:"items,omitempty"` // Hub Subscribing to Real-time Notifications Hub interface{} `json:"-"` // Extensions Publishers can use custom objects in JSON Feeds. Names must start with an _ character followed by a letter. Custom objects can appear anywhere in a feed. Extensions map[string]interface{} `json:"-"` // Authors authors (optional, array of objects) specifies one or more feed authors. The author object has several members. These are all optional — but if you provide an author object, then at least one is required: Authors []*JSONAuthor `json:"authors,omitempty"` // Language language (optional, string) is the primary language for the feed in the format specified in RFC 5646. The value is usually a 2-letter language tag from ISO 639-1, optionally followed by a region tag. (Examples: en or en-US.) Language string `json:"language,omitempty"` }
JSONFeed JSONFeed
func (*JSONFeed) UnmarshalJSON ¶
type JSONItem ¶
type JSONItem struct { // ID id (required, string) is unique for that item for that feed over time. If an item is ever updated, the id should be unchanged. New items should never use a previously-used id. If an id is presented as a number or other type, a JSON Feed reader must coerce it to a string. Ideally, the id is the full URL of the resource described by the item, since URLs make great unique identifiers. ID string `json:"id,omitempty"` // URL url (optional, string) is the URL of the resource described by the item. It’s the permalink. This may be the same as the id — but should be present regardless. URL string `json:"url,omitempty"` // ExternalURL external_url (very optional, string) is the URL of a page elsewhere. This is especially useful for linkblogs. If url links to where you’re talking about a thing, then external_url links to the thing you’re talking about. ExternalURL string `json:"external_url,omitempty"` // Title title (optional, string) is plain text. Microblog items in particular may omit titles. Title string `json:"title,omitempty"` // ContentHTML content_html and content_text are each optional strings — but one or both must be present. This is the HTML or plain text of the item. Important: the only place HTML is allowed in this format is in content_html. A Twitter-like service might use content_text, while a blog might use content_html. Use whichever makes sense for your resource. (It doesn’t even have to be the same for each item in a feed.) ContentHTML string `json:"content_html,omitempty"` // ContentText same as ContentHTML ContentText string `json:"content_text,omitempty"` // Summary summary (optional, string) is a plain text sentence or two describing the item. This might be presented in a timeline, for instance, where a detail view would display all of content_html or content_text. Summary string `json:"summary,omitempty"` // Image image (optional, string) is the URL of the main image for the item. This image may also appear in the content_html — if so, it’s a hint to the feed reader that this is the main, featured image. Feed readers may use the image as a preview (probably resized as a thumbnail and placed in a timeline). Image string `json:"image,omitempty"` // BannerImage banner_image (optional, string) is the URL of an image to use as a banner. Some blogging systems (such as Medium) display a different banner image chosen to go with each post, but that image wouldn’t otherwise appear in the content_html. A feed reader with a detail view may choose to show this banner image at the top of the detail view, possibly with the title overlaid. BannerImage string `json:"banner_image,omitempty"` // DatePublished date_published (optional, string) specifies the date in RFC 3339 format. (Example: 2010-02-07T14:04:00-05:00.) DatePublished string `json:"date_published,omitempty"` // DateModified date_modified (optional, string) specifies the modification date in RFC 3339 format. DateModified string `json:"date_modified,omitempty"` // Author author (optional, object) has the same structure as the top-level author. If not specified in an item, then the top-level author, if present, is the author of the item. Author *JSONAuthor `json:"author,omitempty"` // Tags tags (optional, array of strings) can have any plain text values you want. Tags tend to be just one word, but they may be anything. Note: they are not the equivalent of Twitter hashtags. Some blogging systems and other feed formats call these categories. Tags []string `json:"tags,omitempty"` // Attachments An individual item may have one or more attachments. Attachments []*JSONAttachments `json:"attachments,omitempty"` // Extensions Publishers can use custom objects in JSON Feeds. Names must start with an _ character followed by a letter. Custom objects can appear anywhere in a feed. Extensions map[string]interface{} `json:"-"` // Authors authors (optional, array of objects) has the same structure as the top-level authors. If not specified in an item, then the top-level authors, if present, are the authors of the item. Authors []*JSONAuthor `json:"authors,omitempty"` // Language language (optional, string) is the language for this item, using the same format as the top-level language field. The value can be different than the primary language for the feed when a specific item is written in a different language than other items in the feed. Language string `json:"language,omitempty"` }
JSONItem items is an array, and is required. An item includes:
type RssAuthor ¶
type RssAuthor struct {
Email string `xml:",chardata"`
}
RssAuthor It's the email address of the author of the item. For newspapers and magazines syndicating via RSS, the author is the person who wrote the article that the <item> describes. For collaborative weblogs, the author of the item might be different from the managing editor or webmaster. For a weblog authored by a single individual it would make sense to omit the <author> element.
type RssCategory ¶
type RssCategory struct { // Domain a string that identifies a categorization taxonomy. Domain string `xml:"domain,attr,omitempty"` // Text The value of the element is a forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy. Processors may establish conventions for the interpretation of categories. Text string `xml:",chardata"` }
RssCategory You may include as many category elements as you need to, for different domains, and to have an item cross-referenced in different parts of the same domain.
type RssChannel ¶
type RssChannel struct { Attributes []xml.Attr `xml:",any,attr,omitempty"` // Title The name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website. Title XmlText `xml:"title"` // Link The URL to the HTML website corresponding to the channel. Link string `xml:"link"` // Description Phrase or sentence describing the channel. Description XmlText `xml:"description"` // Language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape, is here. You may also use values defined by the W3C. Language string `xml:"language,omitempty"` // Copyright notice for content in the channel. Copyright string `xml:"copyright,omitempty"` // ManagingEditor Email address for person responsible for editorial content. ManagingEditor string `xml:"managingEditor,omitempty"` // WebMaster Email address for person responsible for technical issues relating to channel. WebMaster string `xml:"webMaster,omitempty"` // PubDate The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred). // TODO w3c pubDate must be an RFC-822 date-time PubDate string `xml:"pubDate,omitempty"` // LastBuildDate The last time the content of the channel changed. LastBuildDate string `xml:"lastBuildDate,omitempty"` // Categories Specify one or more categories that the channel belongs to. Follows the same rules as the <item>-level category element. Categories []*RssCategory `xml:"category,omitempty"` // Generator A string indicating the program used to generate the channel. Generator string `xml:"generator,omitempty"` // Docs A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is. Docs string `xml:"docs,omitempty"` // Cloud Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds Cloud *XmlGeneric `xml:"cloud,omitempty"` // Ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source. Ttl string `xml:"ttl,omitempty"` // Image Specifies a GIF, JPEG or PNG image that can be displayed with the channel. Image *RssImage `xml:"image,omitempty"` // Rating The PICS rating for the channel. Rating *XmlGeneric `xml:"rating,omitempty"` // TextInput Specifies a text input box that can be displayed with the channel. TextInput *RssTextInput `xml:"textinput,omitempty"` // SkipHours A hint for aggregators telling them which hours they can skip. SkipHours *RssSkipHours `xml:"skipHours,omitempty"` // SkipDays A hint for aggregators telling them which days they can skip. SkipDays *RssSkipDays `xml:"skipDays,omitempty"` Items []*RssItem `xml:"item,omitempty"` ExtensionElement []XmlGeneric `xml:",any"` }
type RssContent ¶
type RssEnclosure ¶
type RssFeed ¶
type RssFeed struct { XMLName xml.Name Attributes []xml.Attr `xml:",any,attr,omitempty"` Version string `xml:"version,attr,omitempty"` Channel *RssChannel `xml:"channel,omitempty"` // 0.90 Image *RssImage `xml:"image,omitempty"` Items []*RssItem `xml:"item,omitempty"` TextInput *RssTextInput `xml:"textinput,omitempty"` }
type RssGuid ¶
type RssGuid struct { // IsPermaLink If the guid element has an attribute named isPermaLink with a value of true, the reader may assume that it is a permalink to the item, that is, a url that can be opened in a Web browser, that points to the full item described by the <item> element. IsPermaLink is optional, its default value is true. If its value is false, the guid may not be assumed to be a url, or a url to anything in particular. IsPermaLink string `xml:"isPermaLink,attr,omitempty"` Guid string `xml:",chardata"` }
RssGuid stands for globally unique identifier. It's a string that uniquely identifies the item. When present, an aggregator may choose to use this string to determine if an item is new. There are no rules for the syntax of a guid. Aggregators must view them as a string. It's up to the source of the feed to establish the uniqueness of the string. 2.0.1
type RssImage ¶
type RssImage struct { // Url is the URL of a GIF, JPEG or PNG image that represents the channel. Url string `xml:"url,omitempty"` // Title describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendered in HTML. Title string `xml:"title,omitempty"` // Link is the URL of the site, when the channel is rendered, the image is a link to the site. (Note, in practice the image <title> and <link> should have the same value as the channel's <title> and <link>. Link string `xml:"link,omitempty"` // Width indicating the width of the image in pixels. Maximum value for width is 144, default value is 88. Width string `xml:"width,omitempty"` // Height indicating the height of the image in pixels. Maximum value for height is 400, default value is 31. Height string `xml:"height,omitempty"` // Description contains text that is included in the TITLE attribute of the link formed around the image in the HTML Description string `xml:"description,omitempty"` }
RssImage is an optional sub-element of <channel>, which contains three required and three optional sub-elements.
type RssItem ¶
type RssItem struct { // Title of the item. Title string `xml:"title,omitempty"` // Link The URL of the item. Link string `xml:"link,omitempty"` // Description The item synopsis. Description string `xml:"description,omitempty"` // Email address of the author of the item. Author *RssAuthor `xml:"author,omitempty"` // Categories Includes the item in one or more categories. Categories []*RssCategory `xml:"category,omitempty"` // Comments URL of a page for comments relating to the item. Comments string `xml:"comments,omitempty"` // Enclosure Describes a media object that is attached to the item. Enclosure *RssEnclosure `xml:"enclosure,omitempty"` // Guid A string that uniquely identifies the item. Guid *RssGuid `xml:"guid,omitempty"` // PubDate Indicates when the item was published. PubDate string `xml:"pubDate,omitempty"` // Source The RSS channel that the item came from. Source *RssSource `xml:"source,omitempty"` //Content *RssContent `xml:"content,omitempty"` ContentEncoded *RssContent `xml:"http://purl.org/rss/1.0/modules/content/ encoded,omitempty"` }
type RssSkipDays ¶
type RssSkipDays struct {
Days []string `xml:"day,omitempty"`
}
RssSkipDays An XML element that contains up to seven <day> sub-elements whose value is Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday. Aggregators may not read the channel during days listed in the skipDays element.
type RssSkipHours ¶
type RssSkipHours struct {
Hours []string `xml:"hour,omitempty"`
}
RssSkipHours An XML element that contains up to 24 <hour> sub-elements whose value is a number between 0 and 23, representing a time in GMT, when aggregators, if they support the feature, may not read the channel on hours listed in the skipHours element. The hour beginning at midnight is hour zero.
type RssSource ¶
type RssSource struct { // Url Specifies the link to the source Url string `xml:"url,attr,omitempty"` Text string `xml:",chardata"` }
RssSource Its value is the name of the RSS channel that the item came from, derived from its <title>. It has one required attribute, url, which links to the XMLization of the source. The purpose of this element is to propogate credit for links, to publicize the sources of news items. It's used in the post command in the Radio UserLand aggregator. It should be generated automatically when forwarding an item from an aggregator to a weblog authoring tool.
type RssTextInput ¶
type RssTextInput struct { // Title The label of the Submit button in the text input area. Title string `xml:"title,omitempty"` // Description Explains the text input area. Description string `xml:"description,omitempty"` // Name The name of the text object in the text input area. Name string `xml:"name,omitempty"` // Link The URL of the CGI script that processes text input requests. Link string `xml:"link,omitempty"` }
RssTextInput A channel may optionally contain a <textInput> sub-element, which contains four required sub-elements. The purpose of the <textInput> element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
type UndefinedContent ¶
type UndefinedContent struct { XMLName xml.Name Attributes []xml.Attr `xml:",any,attr,omitempty"` XmlText }
UndefinedContent undefinedContent = (text|anyForeignElement)*
anyElement = element * { (attribute * { text } | text | anyElement)* } anyForeignElement = element * - atom:* { (attribute * { text } | text | anyElement)* }
TODO UndefinedContent