473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML & Javascript parser

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>

Feb 28 '06 #1
8 1607
ri******@gmail. com wrote:
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.


You can't access resources out of your domain name. So you'll need to
make a proxy.

"download.abc?u ri=http://www.live.com"
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 28 '06 #2
That s strange, is it a security restriction of Internet Explorer ?

Feb 28 '06 #3
ri******@gmail. com wrote:
That s strange, is it a security restriction of Internet Explorer ?

Is what? Please quote what you are replying to.

I you are referring to the inability access resources out of your domain
name, its a standard security restriction.

--
Ian Collins.
Feb 28 '06 #4
ri******@gmail. com wrote:
That s strange, is it a security restriction of Internet Explorer ?


It is a restriction of all browsers. XMLHttpRequests can only be made to
the domain that served the page containing the request. There are
significant security issues in doing otherwise.

You can get around that with JSON and dynamically created script elements,
provided the server you want to connect to supports it.

<URL:http://borkweb.com/story/look-ma-cross-domain-scripting>
Look for weather servers that support JSON or JSONP.
--
Rob
Feb 28 '06 #5
RobG wrote:
ri******@gmail. com wrote:
That s strange, is it a security restriction of Internet Explorer ?
It is a restriction of all browsers. XMLHttpRequests can only be made to
the domain that served the page containing the request. There are
significant security issues in doing otherwise.


Specifically, if cross domain XMLHttpRequest was possible, and you
happened to visit a malicious site, what it could do is to simulate a
page submission sequence in your name. That is to say, from the point
of view of that remote domain, it is getting a request from the browser
so as far as it can tell, the browser's user is the one making the
request (Note: one off cross domain requests are available using
I/FRAMEs, but you can't get at them).

Csaba Gabor from Vienna
You can get around that with JSON and dynamically created script elements,
provided the server you want to connect to supports it.

<URL:http://borkweb.com/story/look-ma-cross-domain-scripting>


See also: http://www.json.org/
http://developer.yahoo.net/common/json.html

Mar 2 '06 #6
Thank you very much for your help, and your precious information!

Mar 6 '06 #7

ri******@gmail. com wrote:
Thank you very much for your help, and your precious information!


One other thought. If you are making this page just for yourself, and
you are working on the Windows platform, you can save the web page with
the extension ".hta" : I think it should then run the web page with
fewer security restrictions.

Regards

Julian Turner

Mar 6 '06 #8

ri******@gmail. com wrote:
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?


Hello,

As someone mentioned already, using an AJAX-style callback would
probably work best for this kind of thing. I put together a really
simple AJAX example script, in case you need somewhere to start:

http://www.impliedbydesign.com/super...ming-seed.html

I hope that helps. Good luck!

Chris S.

Free Web Design Tools
http://www.impliedbydesign.com/free-...e-scripts.html

Mar 6 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6002
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the cdata sections will be echoed an not the element names as in the original example. In the cdata sections of my XML file I have terms like this:
4
62095
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I supposed to write this function? String.replace(/</g,'&lt;');
2
3569
by: Thierry Lam | last post by:
Let's say I have the following xml tag: <para role="source">a & b</para> Currently, an xml parser will treat & as a special character. Does anyone know the special characters to use around the ampersand so that the xml parser can treat "a & b" as a whole value? Thanks Thierry
4
3217
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
7
1141
by: Thomas | last post by:
Hi all! Currently I have a web application that consists of a classic frameset. I would like to rebuild the application and just use tables or layers. The problem is, that some parts of the application need to be refreshed at a given interval. Currently, these parts run in a separate frame and a JavaScript function reloads the page every x seconds. In the new scenario I could use iframes, but I would prefer another solution to avoid page...
14
2374
by: madtom1999 | last post by:
I'm trying to put a non-breaking space ( or any other entity for that matter) into a node eg: node.nodeValue+='&nbsp'; however the actual code is written in the html -ie it displays as >&nbsp;< and not > < any ideas?
1
1450
by: xmlnaive | last post by:
i'm a nebie to XML world and I have a weird scenario. If my element looks like this <name>first&amp;last<\name>, the output of the parser is "&last" instead of "first&last". I'm using xereces 2.5 (SAX parser) libs. When i used CDATA,it worked perfectly but not sure why it's behaving weird. Any help/ideas/suggestions would be appreciated. Thanks in advance
3
3544
by: jinendrashankar | last post by:
i am getting following error in my code help me to slove this issue $ gcc -Wall -g -I/usr/include/libxml2/libxml -c create_xml.c In file included from create_xml.c:2: /usr/include/libxml2/libxml/tree.h:20:31: libxml/xmlversion.h: No such file or directory /usr/include/libxml2/libxml/tree.h:880:30: libxml/xmlmemory.h: No such file or directory In file included from create_xml.c:3: /usr/include/libxml2/libxml/parser.h:12:25:...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.