Skip to main content

parse_with_options

Function parse_with_options 

Source
pub fn parse_with_options(
    data: &[u8],
    options: &ParseOptions,
) -> Result<ParsedFeed>
Expand description

Parse feed from raw bytes with full control over parser behavior

This is the most flexible entry point: parse and parse_with_limits are thin wrappers around it. Controls HTML sanitization, relative URI resolution, and resource limits via crate::ParseOptions.

The input is decoded from its BOM or XML declaration, falling back to UTF-8. A declaration that the bytes contradict, or bytes that are invalid in the chosen encoding, set bozo.

§Examples

use feedparser_rs::{parse_with_options, ParseOptions};

// Trust the feed source and skip sanitization
let options = ParseOptions::default().with_sanitize_html(false);
let xml = b"<rss version=\"2.0\"><channel><title>Test</title></channel></rss>";
let feed = parse_with_options(xml, &options).unwrap();

§Errors

Returns FeedError::InvalidFormat if data exceeds the size limit, or the error of a parser that cannot continue. An unrecognized format is not an error; it sets bozo.