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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neilfarah
    New Member
    • Feb 2008
    • 3

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

    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



    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="Micros oft Wordpad>
    <meta name="The 36th Project" content="Miscro soft Wordpad">

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

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


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

    <script LANGUAGE=JavaSc ript>
    [/HTML]
    [CODE=javascript]//create an instance of the XML parser

    function importXML()
    {
    if (document.imple mentation && document.implem entation.create Document)
    {
    var hWin=window.ope n("","RSSINPUT" ,"height=300,wi dth=750,scrollb ars=yes,toolbar =yes,location=y es,directo ries=yes,status =yes,menubar=ye s,scrollbars=ye s,copyhistory=y es,resizable=ye s");
    hWin.document.w rite("<HTML>\n< HEAD>\n<TITLE>X ML&nbsp;Parse&n bsp;Result</TITLE>\n</HEAD>\n");
    hWin.document.w rite("<BO" + "DY>\n");
    hWin.document.w rite("<H2>I entered this URL, "http://www.washingtonp ost.com/wp-dyn/rss/nation/index.xml", But This is blank?</H2>");


    xmlDoc = document.implem entation.create Document("", "", null);
    xmlDoc.onload = createTable;
    }
    else if (window.ActiveX Object)
    {

    var hWin=window.ope n("","RSSINPUT" ,"height=300,wi dth=750,scrollb ars=yes,toolbar =yes,location=y es,directo ries=yes,status =yes,menubar=ye s,scrollbars=ye s,copyhistory=y es,resizable=ye s");
    hWin.document.w rite("<HTML>\n< HEAD>\n<TITLE>X ML&nbsp;Parse&n bsp;Result</TITLE>\n</HEAD>\n");
    hWin.document.w rite("<BO" + "DY>\n");
    hWin.document.w rite("<H2>I entered this URL, "http://www.washingtonp ost.com/wp-dyn/rss/nation/index.xml", But This is blank?</H2>");


    xmlDoc = new ActiveXObject(" Microsoft.XMLDO M");
    xmlDoc.async="f alse" //make sure doc is fully loaded
    xmlDoc.onreadys tatechange = function () {
    if (xmlDoc.readySt ate == 4) createTable()};
    }
    else
    {
    if (xmlDoc.parseEr ror.errorCode != 0) {
    var myError = xmlDoc.parseErr or;
    alert("You have error " + myError.reason) ;

    }
    xmlDoc.load('Re placeMe');

    }

    function createTable()
    {

    var x = xmlDoc.getEleme ntsBytagname("a uthor");
    var newEl = document.create Element('TABLE' );
    newEl.setAttrib ute('cellPaddin g',5);
    var tmp = document.create Element('TBODY' );
    newEl.appendChi ld(tmp);
    var row = document.create Element('TR');
    for (j=0;j<x[0].childNodes.len gth;j++)
    {
    if (x[0].childNodes[j].nodeType != 1) continue;
    var container = document.create Element('TH');
    var theData = document.create TextNode(x[0].childNodes[j].nodeName);
    container.appen dChild(theData) ;
    row.appendChild (container);
    }
    tmp.appendChild (row);
    for (i=0;i<x.length ;i++)
    {
    var row = document.create Element('TR');
    for (j=0;j<x[i].childNodes.len gth;j++)
    {
    if (x[i].childNodes[j].nodeType != 1) continue;
    var container = document.create Element('TD');
    var theData = document.create TextNode(x[i].childNodes[j].firstChild.nod eValue);
    container.appen dChild(theData) ;
    row.appendChild (container);
    }
    tmp.appendChild (row);
    }
    document.getEle mentById('write root').appendCh ild(newEl);
    }
    }[/CODE]

    </script>

    </html>
    Last edited by acoder; Feb 28 '08, 08:46 AM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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).

    Comment

    • neilfarah
      New Member
      • Feb 2008
      • 3

      #3
      Originally posted by acoder
      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

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        See this script - it should be enough for your requirements.

        Comment

        Working...