By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,548 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

Import RSS XML URL launches Blank Window instead of Listings. Please help!!!!

P: 3
This is a xmlDoc.load routine through either IE or Firefox. An RSS URL is loaded into a form. After Onclick of a button a second window is launched and a parsed listing of the original RSS file is supposed to display in a separate window. But I am getting a blank page instead. I've tried this hundred of different waya, including using innerHTML, and or shifting the javascript to the bottom of the page (I thought it might have something to do with the javascript executing before the page was loaded). I cannot use <body onload> because everything must occur after onclicks. So the onclicks are in the header (DHTML), and I've shifted the javascript to the bottom of the page. Please help!!!!!

You can use the following RSS

http://www.washingtonpost.com/wp-dyn...tion/index.xml

HERE'S THE CODE:
[HTML]
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft Wordpad>
<meta name="The 36th Project" content="Miscrosoft Wordpad">

<title>36th Project project</title>
<b><font size=6 face=bold>View Articles</font></b>

<div id=ReplaceMe>Enter XML file</div><BR>
<input id=T1 type=text style="width: 400"><P>
<input type=button value="Submit Query"
onclick="ReplaceMe.innerHTML = T1.value";>


</head>
<body>
<form>
<input type=button value="CONTINUE"
ONCLICK="importXML()";>
</form>
</body>

<script LANGUAGE=JavaScript>
[/HTML]
Expand|Select|Wrap|Line Numbers
  1. //create an instance of the XML parser
  2.  
  3. function importXML()
  4. {
  5. if (document.implementation && document.implementation.createDocument)
  6. {
  7. var hWin=window.open("","RSSINPUT","height=300,width=750,scrollbars=yes,toolbar=yes,location=yes,directo ries=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes");
  8. hWin.document.write("<HTML>\n<HEAD>\n<TITLE>XML&nbsp;Parse&nbsp;Result</TITLE>\n</HEAD>\n");
  9. hWin.document.write("<BO" + "DY>\n");
  10. hWin.document.write("<H2>I entered this URL, "http://www.washingtonpost.com/wp-dyn/rss/nation/index.xml", But This is blank?</H2>");
  11.  
  12.  
  13. xmlDoc = document.implementation.createDocument("", "", null);
  14. xmlDoc.onload = createTable;
  15. }
  16. else if (window.ActiveXObject)
  17. {
  18.  
  19. var hWin=window.open("","RSSINPUT","height=300,width=750,scrollbars=yes,toolbar=yes,location=yes,directo ries=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes");
  20. hWin.document.write("<HTML>\n<HEAD>\n<TITLE>XML&nbsp;Parse&nbsp;Result</TITLE>\n</HEAD>\n");
  21. hWin.document.write("<BO" + "DY>\n");
  22. hWin.document.write("<H2>I entered this URL, "http://www.washingtonpost.com/wp-dyn/rss/nation/index.xml", But This is blank?</H2>");
  23.  
  24.  
  25. xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  26. xmlDoc.async="false" //make sure doc is fully loaded
  27. xmlDoc.onreadystatechange = function () {
  28. if (xmlDoc.readyState == 4) createTable()};
  29. }
  30. else
  31. {
  32. if (xmlDoc.parseError.errorCode != 0) {
  33. var myError = xmlDoc.parseError;
  34. alert("You have error " + myError.reason);
  35.  
  36. }
  37. xmlDoc.load('ReplaceMe');
  38.  
  39. }
  40.  
  41. function createTable()
  42. {
  43.  
  44. var x = xmlDoc.getElementsBytagname("author");
  45. var newEl = document.createElement('TABLE');
  46. newEl.setAttribute('cellPadding',5);
  47. var tmp = document.createElement('TBODY');
  48. newEl.appendChild(tmp);
  49. var row = document.createElement('TR');
  50. for (j=0;j<x[0].childNodes.length;j++)
  51. {
  52. if (x[0].childNodes[j].nodeType != 1) continue;
  53. var container = document.createElement('TH');
  54. var theData = document.createTextNode(x[0].childNodes[j].nodeName);
  55. container.appendChild(theData);
  56. row.appendChild(container);
  57. }
  58. tmp.appendChild(row);
  59. for (i=0;i<x.length;i++)
  60. {
  61. var row = document.createElement('TR');
  62. for (j=0;j<x[i].childNodes.length;j++)
  63. {
  64. if (x[i].childNodes[j].nodeType != 1) continue;
  65. var container = document.createElement('TD');
  66. var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
  67. container.appendChild(theData);
  68. row.appendChild(container);
  69. }
  70. tmp.appendChild(row);
  71. }
  72. document.getElementById('writeroot').appendChild(newEl);
  73. }
  74. }
</script>

</html>
Feb 28 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Move the HTML in the head (lines 10-15) into the body. Also move the JavaScript (which is currently outside the head and body) into the head section (with the script tags too).
Feb 28 '08 #2

P: 3
Move the HTML in the head (lines 10-15) into the body. Also move the JavaScript (which is currently outside the head and body) into the head section (with the script tags too).

I tried that and it didn't work. I know why you suggested it though. But thanks
Feb 28 '08 #3

acoder
Expert Mod 15k+
P: 16,027
See this script - it should be enough for your requirements.
Feb 28 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.