Hi
In order to build a weather prediction page, I was thinking to write
down a Javascript (on the client). This javascript should contact a
server (www.live.com) in ordert to extract the weather forecast.
In summary, I want a javascript based on the html client (internet
Explorer), creating a connection and extractign the data.
This sounds simple but for whatever reason, I cannot manage to extract
any data of this XML page.
Perhaps can you help me?
This code you can past it, as a document by it s own and test it and
complete it for your own pages (the server is ready to answer you).
thanks
<script language="javas cript">
<!--
// Server pages - Parameters.
// URL = <Debut>+CodeVil le+<Fin>
var Debut =
"http://www.live.com/cfw/weatherdata.asp x?wealocations= fr:";
var Fin = "&weadegreetype =C&culture=fr-fr&rand=0.0";
// Objects initialisation
function Weather(code)
{
//Path
this.Code = code; //town code (key)
this.LocationNa me = null; // Full name of the town
this.URL = null; //path for icons
this.ImageRelat iveURL = null; // second part of the path
//Weather of the current day
this.CurrentTem perature = null;
this.Skycode = null; //icon
this.SkyText = null; //description
this.Date = null; //date
this.Day = null; // day of the week
this.Time = null; // time
}
// LThis is the function which has the problem
Weather.prototy pe.GetData = function()
{
// Object creation
var xmlData = new ActiveXObject(" Microsoft.XMLDO M");
xmlData.async=f alse;
// URL
var URL = Debut + this.Code + Fin;
// Check the URL
alert(URL);
// Connection to the XMLwebpage
xmlData.load(UR L);
// Check the connection by displaying any data
alert(xmlData.d ocumentElement. childNodes(1).t ext); // <---- Here
is the error. I tryed with and without 'documentElemen t', but this does
not work
//read data...
alert(xmlData.r oot.children.it em("weatherdata "));
}
// Strasbourg is the town I want to have. initialisation of the Data
var Strasbourg = new Weather("FRm_St rasbourg");
// Strasbourg object receive the data.
Strasbourg.GetD ata();
-->
</script>