Results 1 to 3 of 3
  1.    #1  
    Hi everyone !

    I'm trying to parse xml feeds using the following sdk samples which works great :

    Code:
    function XmlParseAssistant() {
    	this.items = [];
    	this.path = "/artist/albums/album";
    	this.url = 'http://feeds.rhapsody.com/u2/data.xml';
    }
    
    XmlParseAssistant.prototype.setup = function() {
    	this.buttonModel1 = {
    		buttonLabel : 'Parse XML',
    		buttonClass : 'dismiss',
    		disable : false
    	}
    	this.buttonAtt1 = {
    		type : Mojo.Widget.activityButton
    	}
    	
    	this.controller.setupWidget('go_button',this.buttonAtt1,this.buttonModel1)
    	Mojo.Event.listen(this.controller.get('go_button'),Mojo.Event.tap, this.send.bind(this));
    	
    }
    
    XmlParseAssistant.prototype.propertyChange = function (event){
    	/* Kick off a search when the search value changes */
    	this.send();
    }
    
    XmlParseAssistant.prototype.sendContinue = function() {
    	if (Mojo.Host.current === Mojo.Host.mojoHost) {
    		// same original policy means we need to use the proxy on mojo-host
    		this.url = '/proxy?url=' + encodeURIComponent(this.url);
    	}
    	/*
    	 * Use the prototype AJAX object, being sure to use Prototype's
    	 * bind function to make sure the 'this' keyword is set to this
    	 * instance when the callbacks are called.
    	 */
    	var request = new Ajax.Request(this.url, {
    		method: 'get',
    		evalJSON: 'force', //to enforce parsing JSON if there is JSON response
    		onCreate: function(){console.info('******* onCreate happened')},
    		onLoading: function(){console.info('******* onLoading happened')},
    		onLoaded: function(){console.info('******* onLodaed happened')},
    		onSuccess: function(){console.info('******* onComplete happened')},
    		onComplete: this.gotResults.bind(this),
    		onFailure: this.failure.bind(this)
    	});
    }
    
    /*
     * Called by Prototype when the request succeeds. Parse the XML response
     */
    XmlParseAssistant.prototype.gotResults = function(transport) {
    	// Use responseText, not responseXML!! try: reponseJSON 
    	var xmlstring = transport.responseText;	
    	
    	// Convert the string to an XML object
    	var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
    	
    	// Use xpath to parse xml object
    	var nodes = document.evaluate(this.path, xmlobject, null, XPathResult.ANY_TYPE, null);
    	
    	var result = nodes.iterateNext();
    	var i = 0;
    	while (result)
    	{
    	  	// TODO: add list or partial here
    	  	console.log("******* song name: " + result.attributes[0].nodeValue);
    		this.items[i] = result.attributes[0].nodeValue;
    		i++;
    		result=nodes.iterateNext();
    	}
    	
    	// Print out result to the screen
    	this.controller.get('response').update(this.items);
    	this.mybutton = this.controller.get('go_button')
    	this.mybutton.mojo.deactivate();
    }
    Using this code, I want to parse app links from the palm app catalog feed : Web App Updates for US

    So, I've changed the first lines like this

    Code:
    	this.path = "/rss/channel/item";
    	this.url = 'http://developer.palm.com/rss/W/appcatalog.update.rss.xml';
    It doesn't work. Does anyone know where it's wrong? Thanks for answers !
  2. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #2  
    Code:
    	  	console.log("******* song name: " + result.attributes[0].nodeValue);
    		this.items[i] = result.attributes[0].nodeValue;
    In the palm rss feed, <item> has no attributes, so you won't get a thing.
    Apps: MyQ for Netflix (Phone/TouchPad), Giantbomb (Phone), Excavate (Reddit/Digg clients for TouchPad)
  3.    #3  
    Thanks, how to access to app link? should I change this.path ?

Posting Permissions