Function feed_rs::parser::parse_with_uri
source · pub fn parse_with_uri<R: Read>(
source: R,
uri: Option<&str>
) -> ParseFeedResult<Feed>
Expand description
Parse the input (Atom, a flavour of RSS or JSON Feed) into our model
Arguments
input
- A source of content such as a string, file etc.uri
- Source of the content, used to resolve relative URLs in XML based feeds
NOTE: feed-rs uses the encoding attribute in the XML prolog to decode content.
HTTP libraries (such as reqwest) provide a text()
method which applies the content-encoding header and decodes the source into UTF-8.
This then causes feed-rs to fail when it attempts to interpret the UTF-8 stream as a different character set.
Instead, pass the raw, encoded source to feed-rs e.g. the .bytes()
method if using reqwest.
Examples
use feed_rs::parser;
let xml = r#"
<feed>
<title type="text">sample feed</title>
<updated>2005-07-31T12:29:29Z</updated>
<id>feed1</id>
<entry>
<title>sample entry</title>
<id>entry1</id>
</entry>
</feed>
"#;
let feed_from_xml = parser::parse(xml.as_bytes()).unwrap();