web services - Titanium Mobile - Parsing xml response from a soap webservice with suds.js -
i'm trying receive informations soap webservice don't know how display results get.
i can show first global tag named :
this gives me long xml result : response.
when try tagname, doesn't gives result.
here code:
ti.include('suds.js'); var win = ti.ui.createwindow({ backgroundcolor : '#ffffff' }); var view = ti.ui.createscrollview({ layout: 'vertical', contentheight:'auto' }); var label = ti.ui.createlabel({ color : '#000000' }); var url = "http://www.webservicex.net/globalweather.asmx"; var callparams = { countryname : 'belgium' }; var suds = new sudsclient({ endpoint : url, targetnamespace : 'http://www.webservicex.net' }); suds.invoke('getcitiesbycountry', callparams, function(xmldoc) { var response = xmldoc.documentelement.getelementsbytagname('getcitiesbycountryresult'); if (response && response.length > 0) { label.text = response.item(0).text; } else { label.text = 'not ok'; } }); view.add(label); win.add(view); win.open(); the response like:
<newdataset> <table> <country>belgium</country> <city>antwerpen</city> </table> <table> <country>belgium</country> <city>beauvechain</city> </table> </newdataset> the response.length = 1
could display reponse.item(0).text don't want stuff exemple loop gives me cities.
when try change getelementsbytagname('getcitiesbycountryresult') getelementsbytagname('table') message "not ok" appears.
please help, can parse informations need ?
use function working... if want display first tag use getfirstchild(), if want display other tags use getfirstchild().getnextsibling()
Comments
Post a Comment