0
Not a bug

new XML possible bug

Kris 10 months ago in Bugs and problems updated by Vladimir Ovchinnikov 10 months ago 4

Hi,

I am trying to fetch RSS weather data from BBC Weather - https://weather-broker-cdn.api.bbci.co.uk/en/observation/rss/2643743

I have written a code based on other topic on the forum: https://support.iridiummobile.net/communities/18/topics/13554-create-a-tv-guide-xmltv and I came across the same problem with new XML returning null.

This is my code:

IR.AddListener(IR.EVENT_START,0,function()
{
   BBCWRSS.request(); 
});


var BBCWRSS = {};
BBCWRSS.dev =  IR.CreateDevice(IR.DEVICE_CUSTOM_HTTP_TCP, 'BBCWRSS_dev',
    {Host: "weather-broker-cdn.api.bbci.co.uk",
        Port: 80,
        SSL: false,
        ScriptMode: IR.DIRECT_AND_SCRIPT,
        SendCommandAttempts: 0,
        ConnectWaitTimeMax: 3000,
        ReceiveWaitTimeMax: 5000
    });
    
BBCWRSS.request = function (in_callback){
    BBCWRSS.dev.Connect();
        BBCWRSS.dev.SendEx({
            Type: "GET",
            Url: "/en/observation/rss/2643743",
            cbReceiveText: function (text, code, headers) {
                
                if (code != 200) return;
                var resp = new XML(text);
                IR.Log("RESPONSE TEXT:" +text);
                IR.Log("RESPONSE CODE:" +code);
                IR.Log("RESPONSE HEADERS:" +JSON.Stringify(headers));
                IR.Log("RESPONSE RESP XML:" +resp);
                //BUG: new XML returns null
                BBCWRSS.dev.Disconnect();            
                //in_callback(resp);            
                },
            });
}

Can anyone advise on this?

Thanks!

GOOD, I'M SATISFIED
Satisfaction mark by Kris 10 months ago
Under review

Hello.

You are accessing the properties of the XML object incorrectly. Instead of a string:

IR.Log("RESPONSE RESP XML:" +resp);

You need to specify the necessary fields. For example:

IR.Log("title = " + resp.rss.channel["title"]); // title = BBC Weather - Observations for London, GB

Thank you for a quick response!

Works perfectly.

The confusion was that I was expecting an [object Object] output in the console instead of null.