p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For 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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2007, 06:33 PM
Friend of Wrox
Points: 1,376, Level: 14
Points: 1,376, Level: 14 Points: 1,376, Level: 14 Points: 1,376, Level: 14
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jul 2005
Location: , , .
Posts: 298
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems parsing XML Feed in Javascript

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.

KWilliams
__________________
KWilliams
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET XML Feed Error kwilliams ASP.NET 2.0 Professional 0 February 19th, 2008 05:41 PM
Problems parsing XML Feed in Javascript kwilliams Javascript 1 November 7th, 2007 05:59 PM
Parsing XML with Javascript rvanandel Javascript How-To 2 August 29th, 2005 10:37 AM
xml feed with javascript jon8884 Javascript 5 June 22nd, 2005 02:15 PM
XML news feed sankar XML 1 December 17th, 2003 05:28 AM



All times are GMT -4. The time now is 01:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc