cs57109fa-midsec2-V2

cs57109fa-midsec2-V2 - Computer Science 571 MidTerm Section...

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

View Full Document Right Arrow Icon
1 Computer Science 571 MidTerm Section 2 - Prof. Horowitz Thursday, October 8, 2008, 2:00am – 3:15am Name: Social Security or 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 Question 1 [20 pts] XML and JavaScript The following program produces the output immediately after the program. Fill in the missing lines: <html> <body> <script type="text/javascript"> var text="<note>"; text=text+"<to>Sam</to>" ; text=text+"<from>Richard</from>"; text=text+"<heading>Reminder</heading>"; text=text+"<body>Don't forget me this weekend!</body>"; text=text+"</note>"; //Assume that the doc variable has been correctly initialized //as an XML parser doc.loadXML(text); var x= Ques. 1A XXXXXXXXXXXXXXXX document.write("Text of first child element: "); document.write(Ques. 1B XXXXXXXXXXXXXXX); document.write("<br />"); document.write("Text of second child element: "); document.write(Ques. 1C XXXXXXXXXXXXXXXX); </script></body></html> Output Text of first child element: Sam Text of second child element: Richard
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Question 2 [20 pts] XML and JavaScript Given the input: <note> <to>Sam</to> <from>Richard</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> The following web page produces the output shown immediately afterwards. For Ques. 2A, replace Ques. 2A XXXXXXXXXX with the appropriate code, and similarly for the rest of the questions. <html> <body> <script type="text/javascript"> var xmlDoc; if (Ques. 2A XXXXXXXXXXXXXXXX) { xmlDoc= Ques. 2B XXXXXXXXXXXXXX } else if (Ques. 2C XXXXXXXXXXXXXXXX) {xmlDoc= Ques. 2D XXXXXXXXXXXXXXXXX } else {alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load("note.xml"); var x=xmlDoc.documentElement.childNodes; for (var i=0;i<x.length;i++) { if Ques. 2E XXXXXXXXXXXXXXXX) { document.write(Ques. 2F XXXXXXXXXXXXXXXXXXX); document.write(Ques. 2G XXXXXXXXXXXXXXX); document.write("<br />"); } } </script></body></html> Output to: Samuel from: Richard heading: Reminder body: Don’t forget me this weekend
Background image of page 2
3 Question 3 [20 pts] XML and JavaScript Consider the following web page which includes a selection box containing three choices: Division Element, Paragraph Element and Form Element. Below is the source for the above web page with some of the lines missing. Fill in the missing lines. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the 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 / 9

cs57109fa-midsec2-V2 - Computer Science 571 MidTerm Section...

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

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