Classic ASP ProfessionalFor advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
I was initially looking for a solution to parse a remote XML feed into an ASP.NET page using JavaScript, and the code below displays a solution.
The code in this thread works great at pulling nodes from an external XML feed. I have an internal client-side "news scroller" script (JavaScript) that I want to display some of the nodes from the server-side code.
So can I pull XML nodes from an external XML feed, declare variables from that code, and then use those server-side variables within client-side code?
Something like this:
Code:
<%@ LANGUAGE="JAVASCRIPT" %>
<%
var xmlDoc;
xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0")
xmlDoc.async=false;
xmlDoc.setProperty("ServerHTTPRequest", true)
if (xmlDoc.load("http://codeamber.org/a1xl04act/amberalert.xml") == false)
{
Response.Write("Failed to load xml");
}
var amberDescription = xmlDoc.selectSingleNode("//FullText").text;//<<----CAN I PULL THIS INTO CLIENT-SIDE CODE???
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pull XML Feed</title>
<script type="text/javascript" language="javascript">
var pausecontent=new Array()
//These need to be dynamically pulled from existing XML feeds:
pausecontent[0]='<strong><a href="amberalert.aspx">Amber Alert:</a></strong> ' + amberDescription + ' <a href="amberdetails.aspx">Learn more #62;#62;</a>'
pausecontent[1]='<strong><a href="anotherfeed.aspx">Another Feed:</a></strong> ' + anotherfeedDescription + ' <a href="anotherfeed.aspx">Learn more #62;#62;</a>'
//.....MORE JS CODE GOES HERE TO CREATE THE ACTUAL SCROLLER...
}
</script>
</head>
<body>
<h1>Pull XML Feed</h1>
<p><b>Alertstatus:</b> <span id="Alertstatus"><%=xmlDoc.selectSingleNode("//Alertstatus").text %></span><br />
<b>FullText:</b> <span id="FullText"><%=xmlDoc.selectSingleNode("//FullText").text %></span><br />
<b>Alertinfo:</b> <span id="Alertinfo"></span><br />
<b>AlertState:</b> <span id="AlertState"><%=xmlDoc.selectSingleNode("//Alertinfo/@states").text %></span><br />
<b>Victim:</b> <span id="Victim"><%=xmlDoc.selectSingleNode("//Victim/@name").text %></span>
</p>
<script type="text/javascript">
new pausescroller(pausecontent, "scroller", "someclass", 8000)
</script>
</body>
</html>
I don't know much about using client-side code in conjunction with server-side code, so if anyone can let me know if this is possible, that would be great. Thanks.