Home > front end >  Can you help me take a look at this piece of XML HTML applet what's the problem? This applicati
Can you help me take a look at this piece of XML HTML applet what's the problem? This applicati

Time:03-17

This is the HTML code, file name Breakfast_menu. HTML:
 





XML file for a node under certain elements & lt;/title> <br/><meta charset="utf-8" & gt; <br/><script> <br/>If (window. The XMLHttpRequest) {<br/>//code for IE7 +, Firefox, Chrome, Opera, Safari <br/>XMLHTTP=new XMLHttpRequest (); <br/>} <br/>The else {<br/>//code for IE6, IE5 <br/>XMLHTTP=new ActiveXObject (" Microsoft. XMLHTTP "); <br/>} <br/>XMLHTTP. Open (" GET ", "Breakfast_menu. XML", false); <br/>XMLHTTP. The send (); <br/>XmlDoc=XMLHTTP. ResponseXML; <br/>X=xmlDoc. GetElementsByTagName (" food ");//x forget wrote <br/><br/>The function displayFood (I) {<br/>Name=(x [I] getElementsByTagName (" name ") [0]..childnodes [0]. The nodeValue); <br/>Price=(x [I] getElementsByTagName (" price "). [0].childnodes [0]. The nodeValue); <br/>Description=(x [I] getElementsByTagName (" description "). [0].childnodes [0]. The nodeValue); <br/>Calories=(x [I] getElementsByTagName (" calories ") [0]..childnodes [0]. The nodeValue); <br/>TXT="I:" + I + "& lt; Br/& gt; Name: "+ Name +" & lt; Br/& gt; Price: "+ Price + <br/>"& lt; Br/& gt; Description: "+ Description +" & lt; Br/& gt; Calories: "+ Calories; <br/>Document. The getElementById (" showFood "). The innerHTML=TXT;//is getElementById (), not getElementsById (), no s, <br/>} <br/></script> <br/></head> <br/><br/><body> <br/><br/><Div id="showFood" & gt; Click on a Food to display album information. & lt;/div> <br/><Hr> <br/><script> <br/>Document. Write (" & lt; The table border='1' "); <br/>//traverse every food <br/>For (var I=0; i <X.l ength; I++) {<br/>Document. Write (" & lt; Tr onclick=displayFood (" + I + ") & gt;" ); <br/>Document. Write (" & lt; Td>" ); <br/>Document. The write (I); <br/>Document. Write (" & lt;/td> <Td>" ); <br/>Document. The write (x [I] getElementsByTagName (" name ") [0]..childnodes [0]. The nodeValue); <br/>Document. Write (" & lt;/td> <Td>" ); <br/>Document. The write (x [I] getElementsByTagName (" price ") [0]..childnodes [0]. The nodeValue); <br/>Document. Write (" & lt;/td> </tr>" ); <br/>} <br/>Document. Write (" & lt;/table>" ); <br/>Document. The write (" params. Length: "+ x.l ength); <br/><br/></script> <br/><br/></body> <br/><br/></html> <br/></pre> <br/><br/>-- -- -- -- -- -- -- -- -- -- -- -- <br/>This is the XML code, file name Breakfast_menu. XML: <br/><pre> <br/><? The XML version="1.0" encoding="utf-8"?> <! - can also be a code - ISO - 8859-1 & gt; <br/><br/><! -- the XML refer to external CSS styles - & gt; <br/><! - & lt; ? XML - stylesheet type="text/CSS" href="https://bbs.csdn.net/topics/Breakfast_menu.css"?> - & gt; <br/><! -- the XML refer to external students class style - & gt; <br/><? XML - stylesheet type="text/XSL" href="https://bbs.csdn.net/topics/Breakfast_menu.xsl"?> <br/><br/><Breakfast_menu & gt; <br/><Food> <br/><Name> Belgian Waffles</name> <br/><Price> $5.95 & lt;/price> <br/><Description> Two of our famous Belgian Waffles with plenty of real <br/>Maple syrup</description> <br/><Calories> 650 & lt;/calories> <br/></food> <br/><Food> <br/><Name> Strawberry Belgian Waffles</name> <br/><Price> $7.95 & lt;/price> <br/><Description> Light Belgian waffles covered with strawberries and <br/>Whipped cream</description> <br/><Calories> 900 & lt;/calories> <br/></food> <br/><Food> <br/><Name> Berry - Berry Belgian Waffles</name> <br/><Price> $8.95 & lt;/price> <br/><Description> Light Belgian waffles covered with an assortment of fresh <br/>Berries and whipped cream</description> <br/><Calories> 900 & lt;/calories> <br/></food> <br/><Food> <br/><Name> French Toast</name> <br/><Price> $4.50 & lt;/price> <br/><Description> Thick slices made from our homemade sourdough bread <br/></description> <br/><Calories> 600 & lt;/calories> <br/></food> <br/><Food> <br/><Name> Homestyle Breakfast</name> <br/><Price> $6.95 & lt;/price> <br/><Description> Two dense eggs, bacon or sausage, toast, and our (popular <br/>Hash browns</description> <br/><Calories> 950 & lt;/calories> <br/></food> <br/></breakfast_menu & gt; <br/></pre> </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/104842.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/104842.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/104841.html'>Learning js automation scripts can develop page?</a></div> <div class="detail-arr-right">Next:<a href='/frontend/104843.html'>The difference between string template and DOM template</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=HTML+%28CSS%29' target='_blank'>HTML (CSS)</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>