I am facing problem in GetYahooWeatherService while making WeatherApp, Error shows as "Wrapped org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. Cause: Content is not allowed in prolog."
I have changed test AppId with my own created AppId but still not able to resolve this problem.
if(location!=null){
var test=location+" ";
var arrayLocations=test.split(",");
var lat=arrayLocations[0];
var long=arrayLocations[1];
var prm = {
url: "http://query.yahooapis.com/v1/public/yql
q=SELECT%20*%20FROM%20geo.placefinder%20WHERE%20text%3D%22"+lat+","+long+"%22%20and%20gflags%3D%22R%22" /* STRING */,timeout: 60 /* NUMBER*/
};
// result: XML
var xmlPg = Resources["ContentLoaderFunctions"].LoadXML(prm);
var yahoo = new Namespace('http://www.yahooapis.com/v1/base.rng');
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(YahooWeatherFeed)
woeid =xmlPg.results.Result.woeid;
}
var params = {url: "http://xml.weather.yahoo.com/forecastrss?w=" +woeid + "&u=f" /* STRING */,timeout: 60 /* NUMBER */};
// result: XML
var xmlPage = Resources["ContentLoaderFunctions"].LoadXML(params);
var yweather = new Namespace('http://xml.weather.yahoo.com/ns/rss/1.0');
var params = {
infoTableName : "InfoTable",
dataShapeName : "YahooWeatherFeed"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(YahooWeatherFeed)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
for each (var item in xmlPage.channel) {
var row = new Object()
row.Link = xmlPage.channel.item.link;
row.Title = xmlPage.channel.item.title;
row.WeatherCondition = "http://l.yimg.com/a/i/us/we/52/" + xmlPage.channel.item.yweather::condition.@code + ".gif";
row.WeatherTemp = parseInt(xmlPage.channel.item.yweather::condition.@temp.toString());
row.WeatherHumidity = parseInt(xmlPage.channel.yweather::atmosphere.@humidity.toString());
row.WindSpeed = xmlPage.channel.yweather::wind.@speed.toString() + " " + xmlPage.channel.yweather::units.@speed.toString();
row.WindDirection = xmlPage.channel.yweather::wind.@direction.toString();
row.Sunrise = xmlPage.channel.yweather::astronomy.@sunrise.toString();
row.Sunset = xmlPage.channel.yweather::astronomy.@sunset.toString();
row.City = xmlPage.channel.yweather::location.@city.toString();
}
var cityName=xmlPage.channel.yweather::location.@city;
var params = {
url: "http://api.openweathermap.org/data/2.5/weather?q="+cityName+"&type=accurate&mode=xml&APPID=4abc8a3c9f101ccf9c7cfe7cbf3dfed7"
/* STRING */,
timeout: 60 /* NUMBER */
};
var xmlPage = Resources["ContentLoaderFunctions"].LoadXML(params);
var isPrecipitation=xmlPage.precipitation.@mode;
if(isPrecipitation=="no"){
row.Precipitation="No Precipitations";
}
else
{
row.Precipitation=xmlPage.precipitation.@type+" "+xmlPage.precipitation.@value+" "+xmlPage.precipitation.@unit;
}
row.WindDirection=xmlPage.wind.direction.@name;
result.AddRow(row);
This is the code and if there is a problem related to encoding then please tell me that in this code how can i change the encoding to UTF-8
secondly, Since I have my own username and password for login but still sometime website ask me for authentication and it doesn't take my username password.
Can you please give advice?