Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?

Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?

By : Adam Jeo
Date : January 12 2021, 08:33 AM
To fix the issue you can do The problem is how the ajax call and the rendering works. When you execute the program, React tries to render the component directly, so the ajax get call hasn't been completed and the state variable is still empty. Once you receive your response, you update the state with all your news and React update the view. But when it starts, in the render you try to access this.state.news[1], but this.state.news is still an empty empty, so you get the undefined.
A little patch just to allow you to check it is to initialize the state with...
code :
this.state = { news: [{},{}] };
class App extends React.Component {

    constructor(props) { 
        this.state = { news: [{},{}] };

    componentDidMount() {

    getNews() {

        $.get("https://www.hs.fi/rss/tuoreimmat.xml",function(data) {    

            var $xml = $(data);   
            var items = [];

            $xml.find("item").each(function() {
                var $this = $(this);
                    title: $this.find("title").text(),
                    link: $this.find("link").text(),
                    description: $this.find("description").text(),
                    pubDate: $this.find("pubDate").text(),

            this.setState({ news: items });


    render() { 
        return (
            <div className="App">
              <header className="App-header">
                <h1 className="App-title">News</h1>
              <div className="App-feeds">
              <div className="panel-list">{this.state.news[1].title}</div>

Share : facebook icon twitter icon
JQuery: Asynchronously loading DIV tag(only) with latest feed using Google-Ajax-Feed-API

JQuery: Asynchronously loading DIV tag(only) with latest feed using Google-Ajax-Feed-API

By : Shiv Raje
Date : March 29 2020, 07:55 AM
To fix the issue you can do I am writing a code using Google-Ajax-Feed-API to get latest feeds from some site. I want the feeds to be checked for update every(say 1 secs?). I am able to retrieve the blogs but not able to refresh the DIV tags. Any help will be useful.
code :
display name from last fm json feed parsed with jquery

display name from last fm json feed parsed with jquery

By : Robert
Date : March 29 2020, 07:55 AM
wish helps you That's because element.artist is an object. Probably an artist will have a property like element.artist.name. Place a breakpoint in your browser dev tools and inspect the object to see the available properties.
code :
success: function(data) {
    $('body').append($('<div>', {
        text: data.similarartists.artist.map(function(elem) {
            return elem.name;
        }).join(", ")
Rendering RSS Feed Data after Load React Native

Rendering RSS Feed Data after Load React Native

By : Aurélie Palette
Date : March 29 2020, 07:55 AM
hope this fix your issue I determined a pretty effective (and cool) answer! The way that you persist data from an api call is to use ListView, which Facebook has ok information on. A better example of it's use is documented here. Check out the associated github repo here, it is very helpful when connecting the conceptual dots on how it works, so I won't go into detail.
Here's my new (working code):
code :
var React = require('react-native');
var {
} = React;

//additional libraries
var Parse = require('parse/react-native');
//var Reflux = require('reflux');

//dynamic component references
var ArticleView = require('./article-view/article-view');
var Api = require('../utils/api');
var FeedStore = require('../stores/feed-store');
//var Actions = require('../../actions');

var Dimensions = require('Dimensions');
var window = Dimensions.get('window');

module.exports = React.createClass({ 
    componentWillMount: function() {
            .then((user) => { this.setState({user: user}); })
    getInitialState: function() {

        var getSectionData = (dataBlob, sectionID) => {
            console.log("SectionID GIS, getSectionData: " + sectionID);
            return dataBlob[sectionID];

        var getRowData = (dataBlob, sectionID, rowID) => {
            console.log("RowID GIS, getRowData: " + rowID);
            return dataBlob[sectionID + ':' + rowID];

        return {
            user: null, 
            isLoaded: false, 
            dataSource : new ListView.DataSource({
                getSectionData          : getSectionData,
                getRowData              : getRowData,
                rowHasChanged           : (row1, row2) => row1 !== row2,
                sectionHeaderHasChanged : (s1, s2) => s1 !== s2
    componentDidMount: function() {
    organizeData: function() {
        var data_store = null; 
        //get the latest articles on page load
        //this will pre-fill out articles state 
            .then((data) => {
                console.log("data is at home");

                var entries = data, 
                length = entries.length,
                dataBlob = {},
                sectionIDs = [],
                rowIDs = [],
                for (i = 0; i < length; i++)
                    entry = entries[i]; 

                    //add section/row to section id array

                    //mapping section id array for section data 
                    sectionID = entry.title.replace(/\s+/g, '').toLowerCase() + i; 
                    console.log("SectionID = " + sectionID);
                    dataBlob[sectionID] = entry.title; 

                    //mapping row id array for row data 
                    rowIDs[i] = []
                    rowID = sectionID;
                    console.log("RowID = " + rowID);
                    dataBlob[sectionID + ':' + rowID] = entry; 


                    dataSource : this.state.dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs),
                    isLoaded   : true, 

    render: function() {

        if (!this.state.isLoaded) {
            return this.renderLoadingView();

        return this.renderListView();
    renderLoadingView: function() {
        return (
            <View style={styles.container}>
                    style={[styles.activityIndicator, {height: 80}]}
                    size="large" />
    renderListView: function() {
        return (
            <View style={styles.container}>
                    dataSource = {this.state.dataSource}
                    initialListSize = {4}
                    renderRow  = {this.renderRow} />
    renderRow: function (rowData, sectionID, rowID) {
        console.log("Getting my rows on");

        var that = this;
        //call to api to get articles from rss/api var Articles 
        return <ArticleView
                categoryPress={() => { that.dummy }}
                source={{uri: rowData.mediaGroups[0].contents[0].url }}
                onPress={() => { that.dummy }} />

    dummy: function() {

    onChange: function(event, articles) {
        this.setState({articles: articles}); //trigers re-render of component


styles = StyleSheet.create({
    container: {
        flex: 1, 
        alignItems: 'center', 
        justifyContent: 'center',
    activityIndicator: {
        alignItems: 'center',
        justifyContent: 'center',
jQuery - Get the first image from parsed xml feed (content:encoded)

jQuery - Get the first image from parsed xml feed (content:encoded)

By : Neha
Date : March 29 2020, 07:55 AM
around this issue I am able to search through an XML feed with the following code , If your text is:
code :
<p><img src="...">, <img src="...">, <img src="..."></p>
var str = '<p><img src="...">, <img src="...">, <img src="..."></p>';
var firstImg = $($.parseHTML(str)[0]).find('img:first');
var str = '<p><img src="...">, <img src="...">, <img src="..."></p>';
var firstImg = $($.parseHTML(str)[0]).find('img:first');


var t = str.match(/<img[^>]*>/g)[0];

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Empty feed in Facebook page plugin (embedded feed widget)

Empty feed in Facebook page plugin (embedded feed widget)

By : Amin Samandari
Date : March 29 2020, 07:55 AM
should help you out I'm integrating a Facebook Page feed using the Facebook Page Plugin https://developers.facebook.com/docs/plugins/page-plugin ,
This is not a bug, it's a feature
Related Posts Related Posts :
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • Does using try / catch rather than `.catch` observable operator with XHR requests reduce performance?
  • In IE11 background colors not working on printing
  • TypeScript interface signature "(): string"
  • Is synchronous XMLHttpRequest supported in Internet Explorer 10 and 11?
  • Axios function not returning any values with js
  • How to use firestore TIMESTAMP to create time-stamp in JavaScript
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org