1. (50 points) The textarea to the left contains data for the largest 500 cities in Texas (from https://www.homesnacks.net/cities/cities-in-texas/). The data is organized in XML with the following DTD:
<DOCTYPE texascities [ <ELEMENT texascities(city+)> <ELEMENT city(rank,cityname,p1,p2,g)> <ELEMENT rank(#PCDATA)> <ELEMENT cityname(#PCDATA)> <ELEMENT p1(#PCDATA)> <ELEMENT p2(#PCDATA)> <ELEMENT g(#PCDATA)>] When the button labelled execute p1 is clicked the javascript function named p1() is executed. Assume this function loads the XML from the textarea (DO NOT write this part. Assume root is the <texascities> tag). This function then produces:
City loop: for ( i=0; i < root.childNodes.length; i++ ) Rank: root.childNodes[i].childNodes[0].childNodes[0].nodeValue City Name root.childNodes[i].childNodes[1].childNodes[0].nodeValue 2019 Population (p1): root.childNodes[i].childNodes[2].childNodes[0].nodeValue 2010 Population (p2): root.childNodes[i].childNodes[3].childNodes[0].nodeValue Growth Percentage (g): root.childNodes[i].childNodes[4].childNodes[0].nodeValueShow no HTML. Show only the javascript for p1 |
2. (50 points) The form to the left (named "f2") provides the user with choices to display a formatted string in the DIV block named "poster" shown to the left.
|