cs57109fa-midsec2-V2

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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.
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern