Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #11 (permalink)  
Old June 19th, 2007, 11:02 AM
Registered User
 
Join Date: Jun 2007
Location: Worthington, MN, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:The only way is to use a server-side proxy that relays the requests from your server to the real server. Cross domain access is only forbidden on the client, servers have free reign.
Forgive me, for I'm newer to programming, and have much to learn.

So, if for example, my code was this:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>CBS Radio Network NewsFeed</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
var xmlDoc;
function loadXML()
{
// code for IE
if (window.ActiveXObject)
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.load("http://cbsradionewsfeed.com/rss.php?id=32&ud=146");
  getmessage();
  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation &&
document.implementation.createDocument)
  {
  xmlDoc=document.implementation.createDocument("","",null);
  xmlDoc.load("http://cbsradionewsfeed.com/rss.php?id=32&ud=146");
  xmlDoc.onload=getmessage;
  }
else
  {
  alert('Your browser cannot handle this script');
  }
}

function getmessage()
{
document.getElementById("title").innerHTML=
xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
document.getElementById("description").innerHTML=
xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;
}
</script>
</head>

<body onload="loadXML()">
    <div id="CBSFeed">
        <h1><span id="title"></span></h1>
        <p><span id="description"></span></p>
    </div>
</body>
</html>
How would I go about doing this crazy magic you call server-side proxy? =)


Benny_A
----------
Are you not entertAIn3d?
  #12 (permalink)  
Old June 19th, 2007, 11:16 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You'll have to scour Google for examples. Basically you have a web service running on your server that accepts as a parameter the desired URL, 'http://cbsradionewsfeed.com/rss.php?id=32&ud=146', for example. It then loads the content from this URL and passes it back to the original client. As the content is coming from the same domain as the client all is well. I believe Grease Monkey have a server-side proxy that can be used by others, try their site for ideas.

--

Joe (Microsoft MVP - XML)
  #13 (permalink)  
Old May 12th, 2010, 07:01 AM
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Code mentioned by Kalpakavalli.S works fine
Code:
 var fsoXML = new ActiveXObject("Scripting.FileSystemObject");
	var XMlFile = fsoXML.OpenTextFile("C:\\File1.xml",1);
	var Data = XMlFile.ReadAll();
	XMlFile.Close();

      
         loadXML(Data);
A bracket was left opened in OpenTextFile function..That was why Objecr Expected alert comes




Similar Threads
Thread Thread Starter Forum Replies Last Post
Access denied, can't create xml file from ASP.NET goldablasha C# 3 February 27th, 2007 05:50 AM
How to load an xml file that is in same project? tryston02 C# 2005 1 November 28th, 2006 02:50 PM
Getting VB.NET to load & update XML file kyma XML 0 March 19th, 2005 04:58 PM
access denied when uploading file daliaca BOOK: ASP.NET Website Programming Problem-Design-Solution 1 January 16th, 2005 11:08 AM
LOAD A XML FILE FROM JAVASCRIPT nen Javascript How-To 1 December 20th, 2004 11:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.