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

Handling missing tags when parsing feeds #43

Closed
forthrin opened this issue Mar 19, 2023 · 2 comments
Closed

Handling missing tags when parsing feeds #43

forthrin opened this issue Mar 19, 2023 · 2 comments

Comments

@forthrin
Copy link

forthrin commented Mar 19, 2023

RSS::Parser.parse(open('foo.xml')) on a feed that lacks the elements marked NULL gives:

rss-0.2.9/lib/rss/rss.rb:1180:in 'block in _validate': tag <title> is missing in tag <image> (RSS::MissingTagError)

Is there any way to recover from / ignore this? Or must one switch to XML parsing with Nokogiri?

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <link>NULL</link>
    <title></title>
    <description></description>
    <itunes:owner>
      <itunes:name>NULL</itunes:name>
      <itunes:email></itunes:email>
    </itunes:owner>
    <image>
      <link>NULL</link>
      <title></title>
      <url></url>
    </image>
  </channel>
</rss>

@kou
Copy link
Member

kou commented Mar 19, 2023

I couldn't reproduce the error with the given XML.
Is your XML really has an empty <title></title>?

BTW, you can disable the validation by RSS::Parser.parse(open('foo.xml'), false).

@kou kou closed this as completed Mar 19, 2023
@forthrin
Copy link
Author

No, lacks the elements, as in, they are not present at all. The false argument should resolve this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants