Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error whlist parsing hackernoon xml feed #211

Open
n1rjal opened this issue Sep 18, 2023 · 0 comments
Open

Parse error whlist parsing hackernoon xml feed #211

n1rjal opened this issue Sep 18, 2023 · 0 comments

Comments

@n1rjal
Copy link

n1rjal commented Sep 18, 2023

Hello everyone, I got an error while parsing hackernoon page. The error looks like the following. Here is my serde struct
for upto the point where it failed.

#[derive(Serialize, Deserialize, Debug)]
pub struct Rss {
    channel: Channel,
}

#[derive(Debug, Serialize, Deserialize)]
struct Channel {
    #[serde(default)]
    title: String,

    #[serde(default)]
    description: String,

    #[serde(default)]
    image: Option<Image>,

    #[serde(default)]
    item: Vec<Item>,

    #[serde(skip)]
    #[serde(rename = "snf:logo")]
    logo: Option<String>,
}

My console says that the error was the following,

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SerdeError(Syntax { source: Error { pos: 15:18, kind: Syntax("Element snf:logo prefix is unbound") } })', src/main.rs:13:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Finished running. Exit status: 101]

Regarding the error, I am unsure of how is this an error, seems like the package is complaing that the xml feed is not following correct syntax or is there any way to solve this. Thankyou. The hackernoon xml feed can be found below till the part which cause the syntax error.

<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title><![CDATA[Hacker Noon]]></title>
        <description><![CDATA[How hackers start their afternoons.]]></description>
        <link>https://hackernoon.com</link>
        <image>
            <url>https://hackernoon.com/hn-icon.png</url>
            <title>Hacker Noon</title>
            <link>https://hackernoon.com</link>
        </image>
        <generator>RSS for Node</generator>
        <lastBuildDate>Mon, 18 Sep 2023 10:00:14 GMT</lastBuildDate>
        <atom:link href="https://hackernoon.com/feed" rel="self" type="application/rss+xml"/>
        <pubDate>Mon, 18 Sep 2023 10:00:12 GMT</pubDate>
        <snf:logo>https://hackernoon.com/hn-logo.png</snf:logo>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant