【问题标题】:How to parse RSS feed in React Native 0.63?如何在 React Native 0.63 中解析 RSS 提要?
【发布时间】:2020-09-30 06:59:08
【问题描述】:

当我在 Google 上搜索解决方案时,我发现了这个 react-native-rss-parser (https://www.npmjs.com/package/react-native-rss-parser)。

它有这个用法示例:

import * as rssParser from 'react-native-rss-parser';

return fetch('http://www.nasa.gov/rss/dyn/breaking_news.rss')
  .then((response) => response.text())
  .then((responseData) => rssParser.parse(responseData))
  .then((rss) => {
    console.log(rss.title);
    console.log(rss.items.length);
  });

但是当我尝试时

    useEffect(() => {
    fetch('http://www.nasa.gov/rss/dyn/breaking_news.rss')
      .then((response) => response.text())
      .then((responseData) => rssParser.parse(responseData))
      .then((rss) => {
        console.log(rss.title);
        console.log(rss.items.length);
      })
      .catch((err) => console.log(err));
    }, []);

它给了我这个错误:

[TypeError: _this.getElementTextContentArray is not a function. (In '_this.getElementTextContentArray(node, tagName, namespace)', '_this.getElementTextContentArray' is undefined)]

我能做什么?有人知道其他解决方案吗?

【问题讨论】:

    标签: react-native xml-parsing rss rss-reader


    【解决方案1】:

    似乎是与最新版本 1.5.0 相关的问题。

    我开了一个github票: https://github.com/jameslawler/react-native-rss-parser/issues/16

    现在你可以使用 v1.4.0 的 react-native-rss-parser 来让它工作。

    yarn add react-native-rss-parser@1.4.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-28
      • 2012-06-12
      • 2018-01-31
      相关资源
      最近更新 更多