cs57110sp-midsec2 - 1 Computer Science 571 MidTerm Section...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Computer Science 571 MidTerm Section 2 - Prof. Papa Thursday, February 25, 2010, 5:30pm – 6:45pm Name: Student Id Number: 1. This is a closed book exam. 2. Please answer all questions. 3. Place all answers on the exam and return the entire exam DOM QUESTIONS [20 PTS] Below is the Teaching Assistant’s solution to homework #4. You should recall that homework #4 was the XML exercise that involved writing an HTML/JavaScript program, which takes the URL of an XML document containing information related to songs, parses the XML file, and displays results in HTML. The resulting HTML will display a selection list consisting of song titles and a submit button. Selecting a song title and clicking on the submit button will display an HTML table showing the data for the song from the XML file and the song’s video. Some of the code has been removed. Your task is to restore the missing code. Place your answer to the right of the # XXXXXXs . Note that portions of the Firefox implementation have also been removed. There are 10 questions each worth 2 points. <html> <head><title>Assignment 4</title></head> <body> <script LANGUAGE=JavaScript> function generateHTML(xmlDoc) { ELEMENT_NODE = 1; root=xmlDoc.DocumentElement; html_text="<html><head><title>XML Parse Result</title></head><body>"; html_text+="<table align=center><tr><td><form name=\"sform\"> <SELECT name=dropdown>"; if(xmlDoc.documentElement.hasChildNodes()) albums=xmlDoc.documentElement.childNodes; // output out the values for(i=1;i<albums.length;i++) { //Added for FF white spaces if(albums.item(i).nodeType!=ELEMENT_NODE) # XXXXXX1 ; 2 albumNodeList=# XXXXXX2 ; html_text+="<OPTION value=\"<table align =center border=4 bgcolor=gray>"; html_text+="<tr>"; for(k=0;k<albumNodeList.length-2;k++) { if(albumNodeList.item(k).nodeType==ELEMENT_NODE) { if (window.ActiveXObject && k==0) continue; //added to cater for ff whitespaces if (!window.ActiveXObject && k==1) continue; else html_text+="<td><b>"+# XXXXXX3 +"</b></td>"; } } html_text+="</tr><tr> "; albumNodeList2=albums.item(i).childNodes; for(# XXXXXX4 ) { if(albumNodeList2.item(j).nodeType== # XXXXXX5 ) { if (window.ActiveXObject && j==3) vido = albumNodeList2.item(j).firstChild.nodeValue; else if (!window.ActiveXObject && j==7) vido = albumNodeList2.item(j).firstChild.nodeValue; else if (window.ActiveXObject && j==0) var event =...
View Full Document

This note was uploaded on 05/12/2011 for the course CSCI 571 taught by Professor Papa during the Fall '07 term at USC.

Page1 / 10

cs57110sp-midsec2 - 1 Computer Science 571 MidTerm Section...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online