Solved

VBscript XML to  JavaScript XML translation?

Posted on 2007-03-26
9
727 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

626 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