×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Super Contributor
    Join Date
    Nov 2010
    Posts
    1,228

    Cool How to build a Symbian web application by parsing the xml.aspx file instead of rss

    I want to build a Live Tv application with the help of symbian web application by parsing the xml.aspx file like below:



    http://www.yupptv.com/mobile/symbianxml.aspx.



    I have built and tried sample RSS Reader Web app project applications etc in which URL is feeded as blow:


    // Feed name, URL and update frequency (in milliseconds; -1 if no auto update).
    var feedURL="http://blog.ovi.com/feed/rss/";
    var feedName="Ovi blog";
    var feedUpdateFrequency = -1;




    Please suggest How to feed my file url i.e http://www.yupptv.com/mobile/symbianxml.aspx instead of rss

    and get my work done and play the videos.


    what type of video format can be played in s40 devices.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to build a Symbian web application by parsing the xml.aspx file instead of r

    You would simply need to use XML parsing, so feel free to use your favorite search engine for examples for XML parsing with java script.

  3. #3
    Regular Contributor
    Join Date
    Oct 2012
    Posts
    142

    Re: How to build a Symbian web application by parsing the xml.aspx file instead of r

    Hi Yucca

    I have sucessfully parsed the channel names /Title from xml document symbianxml.aspx file by follwoing the example XMLDataSource


    My code is as follows:

    var xmlDataSource = {

    URL: "http://www.yupptv.com/mobile/symbianxml.aspx",

    init: function() {
    //URL, success callback, failure callback
    this.connect(this.URL, this.responseHandler, this.failureHandler);
    },

    /**
    * Parses XML document into JS Object array
    * @param xmlDoc XML Document
    * @returns {Array} array of device objects
    */
    parseResponse: function(xmlDoc) {

    var chElements = xmlDoc.getElementsByTagName("channel");

    var channels = [];

    console.log(chElements.length);

    for(var i=0; i < chElements.length; i++){

    var channel = { };

    for(var j=0; j < chElements[i].childNodes.length; j++){

    var node = chElements[i].childNodes[j];

    if(node.nodeType != 1){ //not an element node
    continue;
    }

    channel[node.tagName] = node.textContent;
    }

    channels.push(channel);
    }
    console.log(channels.length);
    return channels;
    },

    /**
    * Handles the response, and displays device data in web app
    * @param xmlDoc
    */
    responseHandler: function(xmlDoc) {

    var channels = this.parseResponse(xmlDoc);
    var markup = "";

    for(i=0; i < channels.length; i++){

    markup += this.generateHTMLMarkup(i, channels[i]);
    }
    document.getElementById("accordian").innerHTML = markup;
    },

    /**
    * Generates HTML markup to be inserted in to Web App DOM.
    * @index i, index of the device
    * @param device, device object
    */
    generateHTMLMarkup: function(i, channel){

    var str ="";
    str += "<div class='ui-category-list-item-title ui-close' id='item_title_"+i+"'" +
    "onclick=\"mwl.setGroupTarget('#accordian','#items_"+i+"', 'ui-show', 'ui-hide'); " +
    "mwl.setGroupTarget('#accordian','#item_title_"+i+"', 'ui-open', 'ui-close'); return false;\">";
    str += channel['name'] + "</div>";
    str += "<div class='ui-category-list-item-body ui-hide' id='items_"+i+"'>";
    str += "<div class='ui-list'>";
    str += "<div class='ui-list-item'>"+ channel['id'] +"</div>";
    str += "<div class='ui-list-item'>"+ channel['type'] +"</div>";
    str += "<div class='ui-list-item'>"+ channel['language'] +"</div>";
    str += "<div class='ui-list-item'>"+ channel['bandwidth'] +"</div>";
    str += "<div class='ui-list-item'>"+ channel['cellnapid'] +"</div>";
    //str += "<div class='ui-list-item'><img src=\""+ channel['image'] +"\" /></div>";
    str += "<div class='ui-list-item'><a href=\""+ channel['link']+"\">Link</a> </div>";
    str += "</div></div>";
    return str;
    },

    failureHandler: function(reason) {
    document.getElementById("accordian").innerHTML = "Could not get XML document.<br>"+ reason;
    },

    /**
    * Retrieves a XML resource in given URL by using XMLHttpRequest.
    * @param url URL of the XML resource to retrieve
    * @param successCb Called, when the XML resourece is retrieved successfully. Retreived XML Document is passed as argument.
    * @param failCb Called, if something goes wrong. Reason in text format, is passed as argument.
    */

    connect: function(url, successCb, failCb) {

    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("GET", url, true);

    xmlhttp.setRequestHeader("Accept","text/xml,application/xml");
    xmlhttp.setRequestHeader("Cache-Control", "no-cache");
    xmlhttp.setRequestHeader("Pragma", "no-cache");

    var that = this;
    xmlhttp.onreadystatechange = function() {

    if (xmlhttp.readyState == 4 ){

    if(xmlhttp.status == 200){

    if(!xmlhttp.responseXML){
    try {
    //In case server didn't respond with correct MIME type for a XML file.
    var domParser= new DOMParser();
    var xmlDoc = domParser.parseFromString(xmlhttp.responseText,"text/xml");

    successCb.call(that,xmlDoc);

    } catch (e) {
    failCb.call(that,"Response was not in a XML format.");
    }

    }else{
    successCb.call(that,xmlhttp.responseXML);
    }
    }else{
    failCb.call(that,"Connection failed: Status "+xmlhttp.status);
    }
    }
    };
    xmlhttp.send();
    }
    };
















    But Iam not able to parse the Images and show the Channel Images List. Plz help me .

  4. #4
    Regular Contributor
    Join Date
    Oct 2012
    Posts
    142

    Re: How to build a Symbian web application by parsing the xml.aspx file instead of r


  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to build a Symbian web application by parsing the xml.aspx file instead of r

    Generally it usually does not help to open same question in multiple threads, also you did already get Ilkka to answer the first link, so you might want to follow up his advice, you really can not expect all things to be handed ready for you, instead you do need to try out things and do the actual R&D.

Similar Threads

  1. Replies: 1
    Last Post: 2011-05-09, 13:26
  2. 3650: Parsing data-file crashes application
    By tru3playa in forum Mobile Java General
    Replies: 2
    Last Post: 2005-04-16, 13:07
  3. Replies: 0
    Last Post: 2003-12-15, 11:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×