Solved

VBscript XML to  JavaScript XML translation?

Posted on 2007-03-26
9
725 Views
Last Modified: 2013-11-19
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>
0
Comment
Question by:derekfurman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18797736
>>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.
0
 

Author Comment

by:derekfurman
ID: 18797757
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?)
0
 

Author Comment

by:derekfurman
ID: 18797792
dont get me wrong I like the VBscript Im just interested in the Javascript
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18797820
>>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.
0
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 18800258
Why do you need a client-side script for this?  Anyway, here is some example code and I think that javaScript XML pasring has very limit use in reality.

<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
      background-color: #ffffff;
      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>
<script type="text/javascript">
      var xml = new ActiveXObject("Microsoft.XMLDOM");
      xml.async="false";
      if(xml.readyState!=4){
            alert("XML object cannot be initialized");
      }
      else{
      var today = new Date();
      var Dateit = today.getYear()+"-"+(today.getMonth()+1)+"-"+today.getDate();      xml.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");

    var TempNodeList = xml.documentElement.selectNodes("/dwml/data/parameters/temperature/value");
      TempfNodeData0 = TempNodeList[0].firstChild.nodeValue;
    TempfNodeData1 = TempNodeList[1].firstChild.nodeValue;
    TempfNodeData2 = TempNodeList[2].firstChild.nodeValue;

      var WeaNodeList = xml.documentElement.selectNodes("/dwml/data/parameters/conditions-icon/icon-link");
      WeatherPic0 = WeaNodeList[0].firstChild.nodeValue;
      WeatherPic1 = WeaNodeList[1].firstChild.nodeValue;
      WeatherPic2 = WeaNodeList[2].firstChild.nodeValue;

      var CondNodeList = xml.documentElement.selectNodes("/dwml/data/parameters/weather/weather-conditions");
      WeatherCond0 = CondNodeList[0].getAttribute('weather-summary');
      WeatherCond1 = CondNodeList[1].getAttribute('weather-summary');
      WeatherCond2 = CondNodeList[2].getAttribute('weather-summary');
      }

</script>

<table border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr class="topHeader" background="images/pfback.png">
<td width="78" height="40" align="center">
<script type="text/javascript">document.write(TempfNodeData0);</script>&deg;</td>
<td width="78" height="40" align="center">
<script type="text/javascript">document.write(TempfNodeData1);</script>&deg;</td>
<td width="78" height="40" align="center">
<script type="text/javascript">document.write(TempfNodeData2);</script>&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>Renton 47.4828776 -122.2170661<br/>
<script type="text/javascript">
document.write("<br/><br/>");
document.write(WeatherCond0);
document.write("<br/>");
document.write("<img src='"+WeatherPic0+"'/>");

document.write("<br/><br/>");
document.write(WeatherCond1);
document.write("<br/>");
document.write("<img src='"+WeatherPic1+"'/>");

document.write("<br/><br/>");
document.write(WeatherCond2);
document.write("<br/>");
document.write("<img src='"+WeatherPic2+"'/>");
</script>
</p>
</body>
</html>
0
 

Author Comment

by:derekfurman
ID: 18801347
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)
0
 
LVL 9

Expert Comment

by:owenli27
ID: 18801457
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
0
 

Author Comment

by:derekfurman
ID: 18801938
interesting suggest a book I should read on the subject?
0
 
LVL 9

Expert Comment

by:owenli27
ID: 18803228
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Building JSON Results Table FROM DB 9 50
WordPress Page Content Lost 2 50
Scroll listener getting fired on initial page load 2 24
Load XML element 3 43
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question