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
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;
And how exactly the content from the xml will be displayed on the html page? I see no code that puts the values in the To, From and Message divs. Can someone explain?
0
0
Xml should be put on the page by the first box, despite it being left out of the answer…
0
0
before first box it should be “function readXMLFile(){”
after last box it should be “document.getElementById(“to”).innerHTML = …”
0
0
YES
0
0