Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

javascript - 使用React Native解析RSS feed时,如何在description标记内获取description和imageUrl?(How do I get the description and imageUrl inside description tag when parsing an RSS feed using React Native?)

This is how an item from the RSS feed that Im trying to parse looks like:

(这是Im试图解析的RSS feed中的item的样子:)

<item>
<title>
Former cop gets 18 years in prison for shooting civilian to death
</title>
<description>
<![CDATA[
<a href="https://e.vnexpress.net/news/news/former-cop-gets-18-years-in-prison-for-shooting-civilian-to-death-4020110.html"><img width=130 height=100 src="https://i-english.vnecdn.net/2019/11/30/phuoc146331574997301-157508140-8364-4799-1575086150_180x108.jpg" ></a></br>A Dong Nai court sentenced a former traffic policeman to 18 years in prison on Friday for fatally shooting a man in a family feud.
]]>
</description>
<pubDate>Sat, 30 Nov 2019 12:00:00 +0700</pubDate>
<link>
https://e.vnexpress.net/news/news/former-cop-gets-18-years-in-prison-for-shooting-civilian-to-death-4020110.html
</link>
<guid>
https://e.vnexpress.net/news/news/former-cop-gets-18-years-in-prison-for-shooting-civilian-to-death-4020110.html
</guid>
<slash:comments>0</slash:comments>
</item>

This is how I get the title from the RSS feed, I'm using react-native-rss-parser ( https://www.npmjs.com/package/react-native-rss-parser ):

(这是我从RSS feed获得title的方式,我正在使用react-native-rss-parserhttps://www.npmjs.com/package/react-native-rss-parser ):)

fetch('https://vnexpress.net/rss/tin-moi-nhat.rss')
     .then((response) => response.text())
     .then((responseData) => rssParser.parse(responseData))
     .then((rss) =>  { 
         this.setState(prevState => ({
             ...prevState,

             title0: rss.items[0].title
         }))    
     })
const Feeds = ([
        {
        pic: require('../assets/images/image.jpg'), 
        title: Object.keys(this.state.title0).map(k => this.state.title0[k]),
        caption: ''
      },
])

I'm trying to parse the description and the imageUrl which is nested inside the description tag.

(我正在尝试解析description和嵌套在描述标签内的imageUrl 。)

How would I do that?

(我该怎么做?)

Any suggestions?

(有什么建议么?)

  ask by DarkLord666 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...