Documentation
¶
Index ¶
- Constants
- func DecodeEntities(str string) string
- func FindRoot(p *xpp.Parser) (event xpp.EventType, err error)
- func ForEachChild(p *xpp.Parser, handle func(name string) error) error
- func IsExtension(p *xpp.Parser) bool
- func NewControlCharFilterReader(r io.Reader) io.Reader
- func NewReaderLabel(label string, input io.Reader) (io.Reader, error)
- func NewXMLParser(r io.Reader) *xpp.Parser
- func NextTag(p *xpp.Parser) (event xpp.EventType, err error)
- func ParseDate(ds string) (t time.Time, err error)
- func ParseExtension(fe ext.Extensions, p *xpp.Parser) (ext.Extensions, error)
- func ParseNameAddress(nameAddressText string) (name string, address string)
- func ParseText(p *xpp.Parser) (string, error)
- func ParseTextURL(p *xpp.Parser) (string, error)
- func PrefixForNamespace(space string, p *xpp.Parser) string
- func ResolveHTML(base *url.URL, relHTML string) (string, error)
- func ResolveURLIfBase(base *url.URL, s string) string
- func StripCDATA(str string) string
- func XmlBaseResolveUrl(b *url.URL, u string) (*url.URL, error)
Constants ¶
const CDATA_END = "]]>"
const CDATA_START = "<![CDATA["
Variables ¶
This section is empty.
Functions ¶
func DecodeEntities ¶
DecodeEntities decodes escaped XML entities in a string and returns the unescaped string
func FindRoot ¶ added in v1.2.1
FindRoot iterates through the tokens of an xml document until it encounters its first StartTag event. It returns an error if it reaches EndDocument before finding a tag.
func ForEachChild ¶ added in v1.4.0
ForEachChild advances through the children of the element the parser is currently on, calling handle for each child start tag with its lowercased local name. handle must fully consume the child element, by parsing or skipping it. ForEachChild returns once it reaches the enclosing element's end tag, leaving the parser on it, so callers can assert it with Expect.
func IsExtension ¶
IsExtension returns whether or not the current XML element is an extension element (if it has a non empty prefix)
func NewControlCharFilterReader ¶ added in v1.4.0
NewControlCharFilterReader wraps r and drops the C0 control bytes that are illegal in XML (bytes below 0x20 other than tab, LF, and CR). Those byte values are identical across UTF-8 and the single-byte encodings feeds use, and never occur inside a multi-byte UTF-8 sequence, so filtering them on the raw stream is safe regardless of the declared encoding. This lets feeds with stray control characters parse instead of failing outright.
func NewXMLParser ¶ added in v1.4.0
NewXMLParser returns a pull parser configured the way every gofeed parser needs it: non-strict, so real-world feeds with unescaped entities and other common mistakes still tokenize, and with charset conversion for feeds that declare a non-UTF-8 encoding.
func NextTag ¶ added in v1.2.1
XMLBase.NextTag iterates through the tokens until it reaches a StartTag or EndTag. It resolves urls in tag attributes relative to the current xml:base.
NextTag is similar to goxpp's NextTag method except it wont throw an error if the next immediate token isnt a Start/EndTag. Instead, it will continue to consume tokens until it hits a Start/EndTag or EndDocument.
func ParseDate ¶
ParseDate parses a given date string using a large list of commonly found feed date formats.
func ParseExtension ¶
ParseExtension parses the current element of the XMLPullParser as an extension element and updates the extension map
func ParseNameAddress ¶
ParseNameAddress parses name/email strings commonly found in RSS feeds of the format "Example Name (example@site.com)" and other variations of this format.
func ParseText ¶
ParseText is a helper function for parsing the text from the current element of the XMLPullParser. This function can handle parsing naked XML text from an element.
func ParseTextURL ¶ added in v1.4.0
ParseTextURL is ParseText for an element whose text is a URL: it resolves the value against the element's xml:base when one is in scope. The base is captured before ParseText runs, because ParseText consumes the element's end tag, which pops the base off the stack.
func PrefixForNamespace ¶ added in v1.3.0
func ResolveHTML ¶ added in v1.2.1
Transforms html by resolving any relative URIs in attributes if an error occurs during parsing or serialization, then the original string is returned along with the error.
func ResolveURLIfBase ¶ added in v1.4.0
ResolveURLIfBase resolves s against base when an xml:base is in scope, returning s unchanged when base is nil or resolution fails. Element-content URLs (e.g. an RSS <link>) don't pass through resolveAttrs, so this lets them be resolved the same way attribute URLs already are. Resolving only when a base is present means URLs in feeds without xml:base are never round-tripped through url.Parse and so are never normalized.
func StripCDATA ¶
StripCDATA removes CDATA tags from the string content outside of CDATA tags is passed via DecodeEntities
Types ¶
This section is empty.