Solved

Loading External XML file: works server-side, but not client-side

Posted on 2004-08-23
8
221 Views
Last Modified: 2010-04-06
I have to display a Yahoo! news feed on a webpage. This URL tells how to do it: http://www.elise.com/mt/archives/000242displaying_an_rss_newsfeed_on_your_site.php.

The logic is simple, and it works great:
1. Create an object and load your xsl file (which I created)
2. Create an object and load your xml file (the Yahoo! news feed)
3. Use the "transformNode" method for your output.

Trouble is, it uses ASP, and I must use html. I tried to 'convert' the ASP code into clientside javascript, and it works fine -- on my computer. But then when I upload the html file to my server and run it, I get "access denied" on the line that tries to open the Yahoo! feed. The code is below.

I tried the following variations, but none of them solved the problem:
1. Instead of Microsoft.XMLDOM, Msxml2.DOMDocument
2. Instead of Microsoft.XMLDOM, Msxml2.DOMDocument.4.0
3. The command: xmldoc.setProperty("ServerHTTPRequest", true)

Now you have the complete context, but what it really boils down to is loading an external xml file from clientside javascript. Maybe it is not possible?

Any solutions would be very welcome. Thank you.

Here is the code:

<html>
<body></body>
<script>
xsldoc = new ActiveXObject("Microsoft.XMLDOM")
xsldoc.async = false
xsldoc.load("rss.xsl")
xmldoc = new ActiveXObject("Microsoft.XMLDOM")
xmldoc.async = false
xmldoc.load("http://rss.news.yahoo.com/rss/mideast")      <!--HERE IS THE PROBLEM-->
document.write(xmldoc.transformNode(xsldoc))
</script>
</html>
0
Comment
Question by:yisraelharris
[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
  • 3
  • 2
8 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 35 total points
ID: 11873939
You are not going to do it client side!  That is cross-domain scripting and it is prevented by built in security; and you would not want to use a browser that allowed it.  You say you don't have ASP.  So what so you have server side?  What you can do all depends on what you can or cannot do from your server, because its not going to happen on the client; and even if that code did work it is IE only.

Cd&
0
 

Author Comment

by:yisraelharris
ID: 11874445
Understood. Your explanation makes sense.

You ask what I have server side. The answer is that the Yahoo! feed needs to be displayed on a blog which is created through typepad.com. I am not sure what server side functionality they provide for displaying external files. I have just opened a help ticket with them, so we shall see.

I wonder if perhaps I will need to use a totally different technology for accessing a remote news feed in typepad.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11875049
If it is free hosting on Yahoo, you probably won't have much hope; but if it is paid hosting they will probably have something you can use.  Without being able to do something server side there is not much you are going to be able to do other then just display the raw feed which is not a real alternative.

Cd&
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

Author Comment

by:yisraelharris
ID: 11877154
Typepad suggested that I use feedroll.com.

This seems like a possible solution. However, to use feedroll, you need to provide the source_id of the rss news feed you wish to display. I do not know the source_id for Yahoo! Mideast News. Any idea how I can determine this? (I have already submitted the question to Yahoo!.)
0
 
LVL 2

Assisted Solution

by:Epistemo
Epistemo earned 35 total points
ID: 11948164
feedroll has their id in their RRS format. This means that this is currently not available.
So instead of contacting Yahoo ... (they do not know the ID either since it is feeroll) you need to
contact feedroll and have them create the correct ID for you. They already have the Yahoo API it
seems and so that shouldn't take them to long.

You can't run any server scripts on Typepad?
0
 

Author Comment

by:yisraelharris
ID: 11950410
Thank you. I did indeed contact feedroll, and they very promptly got back to me with the correct ID. So I did indeed end up using feedroll.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

728 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