Solved

VBscript XML to  JavaScript XML translation?

Posted on 2007-03-26
9
717 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>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
Comment Utility
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
Comment Utility
dont get me wrong I like the VBscript Im just interested in the Javascript
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
interesting suggest a book I should read on the subject?
0
 
LVL 9

Expert Comment

by:owenli27
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now