How should you create the JavaScript code?

DRAG DROP
You have a webpage that includes the following markup:

An XML file named message.xml resides on a web server. The structure of the file is as follows:

You are developing a code-based solution to parse the contents of the XML file and display the
information on the page.
The solution must work on both modern and older browsers.
You need to display the information from the XML file onto the page.
How should you create the JavaScript code? (Develop the solution by selecting the required code
segments and arranging them in the correct order. You may not need all of the code segments.)

DRAG DROP
You have a webpage that includes the following markup:

An XML file named message.xml resides on a web server. The structure of the file is as follows:

You are developing a code-based solution to parse the contents of the XML file and display the
information on the page.
The solution must work on both modern and older browsers.
You need to display the information from the XML file onto the page.
How should you create the JavaScript code? (Develop the solution by selecting the required code
segments and arranging them in the correct order. You may not need all of the code segments.)

Answer: See the explanation.

Explanation:

Box 1:

Box 2:

Box 3:

Box 4:

Box 5:

Box 6:

Box 7:

Note:
Parse an XML Document
Example. The following code fragment parses an XML document into an XML DOM object:

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;



Leave a Reply 11

Your email address will not be published. Required fields are marked *


Tim

Tim

What about Box 8?
Shouldn´t the Content of xmlDoc be placed on the page?

Damien

Damien

I agree with Tim. The code should start with the function box and end with the document.getElementById box. Everything else should fit in the middle, as it is, to complete the answer.

Fabian

Fabian

For me the order of the boxes should be:

8, 6, 4 , 3, 2 , 5 , 9, 7, 1

Thiago Fonseca

Thiago Fonseca

+2

SOUMAIRI

SOUMAIRI

I agree with Fabian

johanna

johanna

Can you please update this questions,I nearly failed yesterday because there are so many new questions i.e Targets

Sihle

Sihle

johhana I am writting nxt week can you please update me with those new question, Please