xml - JavaScript appendChild Not Working/Completing -
i've been working on project creates image map using data stored in xml file. far can tell, code makes end fails on "mapgoeshere.appendchild(mapstructure);" line of code. code in entirety...basically scroll down bottom reach processroomdata function believe code dying:
function loadsinglexml(filetoload, howtohandle) { var xmldoc = new activexobject ("microsoft.xmldom"); xmldoc.async="false" xmldoc.load(filetoload); alert("xmldoc.load(filetoload)"); var errorcode = xmldoc.readystate; if (errorcode == 4) { howtohandle(xmldoc); alert("howtohandle(xmldoc)"); } else { alert("unable load document " + url + "\n error: " + errorcode); } } function createroomdata(xmlrooms) { var roomdata = new array(); roomdata.roomcount = rooms.length; (var r=0; r<xmlrooms.length; ++r) { roomdata[r] = new object(); roomdata[r].portlist = xmlrooms[r].getattribute("ports"); roomdata[r].number = xmlrooms[r].getattribute("number"); roomdata[r].occlist = xmlrooms[r].getattribute("occupant"); roomdata[r].coordlist = xmlrooms[r].getattribute("coords"); } return roomdata; } function createmapstructure (xmlroomdata) { var mapstructure; var roomdata; var area; rooms = xmlroomdata.getelementsbytagname("room"); roomdata = createroomdata(rooms); mapstructure = document.createelement("map"); (var r=0; r<roomdata.length; ++r) { area = document.createelement("area"); area.setattribute("name", roomdata[r].numberslist); area.setattribute("shape", "rect"); area.setattribute("coords", roomdata[r].coordlist); area.setattribute("onmouseover", "return overlib('" + roomdata[r].portlist + "', caption, '" + roomdata[r].occlist + "');"); area.setattribute("onmouseout", "nd();"); mapstructure.appendchild(area); } return mapstructure; } var maplocation = "xml/floorone.xml"; function processroomdata(mapdata) { mapstructure = createmapstructure(mapdata); alert("completed: createmapstructure"); mapstructure.setattribute("name", "portmap"); alert("completed: setattribute"); mapgoeshere = document.getelementbyid("portnumbs"); alert("completed: getelementbyid"); mapgoeshere.appendchild(mapstructure); alert("completed: appendchild"); } loadsinglexml(maplocation, processroomdata); in processroomdata function @ bottom added alert after each step try figure out code hanging up. last alert (completed: appendchild) not appear, leading me believe code getting hung on specific line of code. unfortunately, not know enough programming understand why. kind enough point out error of ways , explain in manner novice programmer understand? thank you.
edit: thought html side of things may relevant, too, here's html. there isn't much.
<html> <head> <title>combo test</title> <script type="text/javascript" src="javascript/overlib.js"></script> <script type="text/javascript" src="javascript/xml-ie-load.js"></script> </head> <body> <div id="overdiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> <img width="1673" height="1293" src="images/floor1.png" border="2" ismap usemap="#portmap" /> <div id="portnumbs"></div> </body> </html> edit: per request, here sample of xml being loaded:
<eoc xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="floor.xsd"> <facility location="northpointe"> <floor level="one"> <room number="" occupant="grace (7126)" ports="unknown/inaccessible" coords="1448,680,1523,717"/> <room number="100" occupant="brian (7010)" ports="001, 002, 003" coords="465,173,527,214"/> <room number="" occupant="hl-5250dn (6392)" ports="050" coords="564,229,580,262"/> <room number="101a" occupant="richard (7038)" ports="013, 014(c), 015(p)" coords="554,155,608,203"/> <room number="101b" occupant="tbd" ports="016, 017, 018(c)" coords="617,155,666,200"/> <room number="101c" occupant="jamie (7173)" ports="019(c), 020(p), 021" coords="675,158,730,202"/> <room number="101d" occupant="lucas (7145)" ports="unknown/inaccessible" coords="737,158,791,200"/> <room number="101e" occupant="dave (7100)" ports="unknown/inaccessible" coords="799,157,852,198"/> <room number="101f" occupant="eliot (7112)" ports="028(c), 029(c), 030(p)" coords="859,158,912,198"/> </floor> </facility> </eoc> if view full, working project, visit newmap.levitonet.com in either firefox or internet explorer. on main page of project browser detection loads either firefox or ie version of javascript file. both files identical except first "loadsinglexml" function. project works , displays fine in firefox not work in internet explorer.
Comments
Post a Comment