Link to home
Start Free TrialLog in
Avatar of derekfurman
derekfurman

asked on

VBscript XML to JavaScript XML translation?

Hi I got this working with the help of u experts some of you have said that this would be better handled by java script. I know this is a lot to ask but could someone translate the VBscript to JavaScript. Thank you I am very interested in the results.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Connect XML -->
<%Dim objXML,TempfNodeData0,TempfNodeData1,TempfNodeData2,WeatherCond0,WeatherCond1,WeatherCond2,WeatherPic0,WeatherPic1,WeatherPic2,Dateit
Dateit = Date
set objXML = CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", true
objXML.Load ("http://www.weather.gov/forecasts/xml/SOAP_server/ndfdSOAPclientByDay.php?lat=47.4828776&lon=-122.2170661&format=24+hourly&startDate=" & Dateit &"&numDays=4&Submit=Submit")
If not objXML.parseError.errorCode <> 0 then
    TempfNodeData0 = objXML.selectsingleNode("/dwml/data/parameters/temperature/value[1]").text
      TempfNodeData1 = objXML.selectsingleNode("/dwml/data/parameters/temperature/value[2]").text
      TempfNodeData2 = objXML.selectsingleNode("/dwml/data/parameters/temperature/value[3]").text
      WeatherPic0 = objXML.selectsingleNode("/dwml/data/parameters/conditions-icon/icon-link[1]").text
      WeatherPic1 = objXML.selectsingleNode("/dwml/data/parameters/conditions-icon/icon-link[2]").text
      WeatherPic2 = objXML.selectsingleNode("/dwml/data/parameters/conditions-icon/icon-link[3]").text
      WeatherCond0 = objXML.selectsingleNode("/dwml/data/parameters/weather/weather-conditions[1]").Attributes.getNamedItem("weather-summary").nodeValue
      WeatherCond1 = objXML.selectsingleNode("/dwml/data/parameters/weather/weather-conditions[2]").Attributes.getNamedItem("weather-summary").nodeValue
      WeatherCond2 = objXML.selectsingleNode("/dwml/data/parameters/weather/weather-conditions[3]").Attributes.getNamedItem("weather-summary").nodeValue
      'fso.copyFile "n:\pixelfire\images\" & conPATH &"\" & tempBMP, "n:\pixelfire\images\current.jpg"
end if
Set objXML = Nothing %>
<!-- XML loaded for parsing End -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
      background-color: #000000;
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
}
.topHeader {
      font-family: Tahoma, Geneva, Arial, Helvetica, Sans-serif;
      font-size: 24px;
      background-image: url(images/pfbackyello.jpg);
      font-weight: bold;
      color: #0000CC;
}
.Bottr {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 24px;
      font-weight: bold;
      color: #FFF300;
      background-image: url(images/pfback2.jpg);
}
.style23 {font-size: 24px; font-family: Tahoma, Geneva, Arial, Helvetica, Sans-serif; font-weight: bold; color: #FFFF00; }
.style24 {
      color: #FFFFFF;
      font-family: Tahoma, Geneva, Arial, Helvetica, Sans-serif;
}
.Graphix {
      background-image: url(images/bk.gif);
}
-->
</style>
</head>

<body>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="topHeader" background="images/pfback.png">
<td width="78" height="40" align="center">
<%response.write TempfNodeData0 %>&deg;</td>
<td width="78" height="40" align="center">
<%response.write TempfNodeData1 %>&deg;</td>
<td width="78" height="40" align="center">
 <%response.write TempfNodeData2 %>&deg;</td>
</tr>
<tr class="Graphix">
<td width="78" align="center" bgcolor="#003366"><img src="images/clearsun.gif" alt="today" width="60" height="57" /></td>
<td width="78" align="center" bgcolor="#333333"><img src="images/clearsun.gif" alt="today" width="60" height="57" /></td>
<td width="78" align="center" bgcolor="#333333"><img src="images/cloud.gif" alt="Day after tomorrow" width="60" height="57" /></td>
</tr>
<tr bgcolor="#000099" class="Bottr">
<td width="78" height="40" align="center" class="style23">TUE</td>
<td width="78" height="40" align="center" class="style23">WED</td>
<td width="78" height="40" align="center" class="style23">THUR</td>
</tr>
</table>
<p>&nbsp;</p>
<p><span class="style24">Renton 47.4828776 -122.2170661</span><br />
<span class="style24">
<%response.write WeatherCond0 %>
<br />
<%response.write WeatherCond1 %>
<br />
<%response.write WeatherCond2 %>
<br />
<%response.write WeatherPic0 %>
<br />
<%response.write WeatherPic1 %>
<br />
<%response.write WeatherPic2 %>
</span></p>
</body>
</html>
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

>>Hi I got this working with the help of u experts some of you have said that this would be better handled by java script.<<
Actually, I believe the comment you are referring to (made by owenli27) was:
"If it was Java code, I can do it much better. "

Not sure if you realize that Java <> JavaScript

Just my 2 cents worth.
Avatar of derekfurman
derekfurman

ASKER

I do know that Java and javascript and even Jscript do not =
And I am referring to previous xml posts I have done here and other boards
it is just not the first time I have heard it owenli27

(Kind of strange response but I'll take what I can get will you contribute?)
dont get me wrong I like the VBscript Im just interested in the Javascript
>>dont get me wrong I like the VBscript Im just interested in the Javascript<<
Fair enough, I just wanted to make sure you realized that Java is compiled code and that ASP only supports VBScript and JavaScript.

Hopefully someone will step up to the plate.
ASKER CERTIFIED SOLUTION
Avatar of Weiping Du
Weiping Du
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you owenli27 this is a great example. (I understand this)

What do you mean: “Why do you need a client-side script for this?” is there a better way to handle this?

Please explain I don’t understand but I want to :)

You also said: “JavaScript XML parsing has very limit use in reality.”
Do you mean just java or VBScript as well?

What about XHTML can this be handed with out using asp?

(so many questions lucky I have you experts)
Normally, a client (let's say it is a browser) sends request to a server.  Then, server code (Java or VBScript) to download or query XML source data;  parsing XML and extract element or attributes; finally return HTML and result data to client(a browser).   But What I did above is that JavaScript running on browser and download XML directly to your PC buffer and parsing data locally in client-side.  This is not client-server principle and we can see it in few cases
interesting suggest a book I should read on the subject?
I really don't know any books I should recommend them since I graduated from school 8 years ago. :)
If you just want to know something, focus on client/server. Here is a link

http://www.uow.edu.au/~nabg/WebServer/

http://www.amazon.com/Web-Server-Programming-Neil-Gray/dp/0470850973/ref=pd_bbs_sr_1/102-7172892-8909769?ie=UTF8&s=books&qid=1175026144&sr=1-1