[AC-2879] I am trying to call webservices file in our Application, but i am getting error, there is no proper documentation availbale that how to access remote xml webservices in Titanium
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-02-23T10:11:57.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | branch-v8, tbs-1.9.0 |
Reporter | Bharat Bhushan |
Assignee | Mauro Parra-Miranda |
Created | 2012-02-08T01:53:32.000+0000 |
Updated | 2016-03-08T07:47:50.000+0000 |
Description
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
Ti.API.info('twitter xml ' + this.responseXML + ' text ' + this.responseText);
var doc = this.responseXML.documentElement;
var elements = doc.getElementsByTagName("screen_name");
var screenName = elements.item(0);
Ti.API.info("screenname = " + screenName.text);
var screenname = Ti.UI.createLabel({
textAlign:'center',
height:'auto',
width:'auto',
top:20,
text:screenName.text
});
Ti.UI.currentWindow.add(screenname);
var textarea = Ti.UI.createTextArea({borderRadius:5,borderWidth:2,borderColor:'#999',backgroundColor:'#111',color:'yellow',bottom:10,left:10,right:10,height:300,font:{fontFamily:'courier',fontSize:10}});
textarea.value = this.responseText;
Ti.UI.currentWindow.add(textarea);
};
xhr.open('GET', 'http://202.53.15.170/aguva/php_xml/php_xml.php?GetOpr=GetTopBizList');
xhr.send();
Did you see the document at https://wiki.appcelerator.org/display/guides/Working+with+XML+Data
Moved from TISTUD tracker.
I am getting this error when i use this code in app.js : var xhr = Ti.Network.createHTTPClient(); xhr.open("GET","http://v2.0.news.tmg.s3.amazonaws.com/feeds/news.xml"); xhr.onload = function() { try { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("item"); var x = 0; var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue; for (var c=0;c
With a quick glance, I'm going to guess that this line is what's causing the error: doc.evaluate("//channel/title/text()").item(0).nodeValue; Instead, you should use something like:
Check out the code at the following location. I updated it to pull from the RSS feed you're trying to use. It loads up the stories just fine. You can see in it how I "walk" the XML tree (see the network.js file). This example project uses the same techniques described in the wiki. https://github.com/skypanther/TitaniumIntro/tree/master/RSSReader You're welcome to use the code in that repo in your project, it's Apache FOSS licensed.
Following Tim's example, this is working fine.
Invalid issue.