Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态生成的锚HREF,用于调用不工作的函数_Javascript_Html_Xml_Dynamic_Html Table - Fatal编程技术网

Javascript 动态生成的锚HREF,用于调用不工作的函数

Javascript 动态生成的锚HREF,用于调用不工作的函数,javascript,html,xml,dynamic,html-table,Javascript,Html,Xml,Dynamic,Html Table,如果已经有人问过这类问题,我表示歉意,但我已经仔细阅读了“相关问题”,我认为这里的任何内容都与我的不匹配,所以请耐心等待,因为我试图提出我的问题,以及我将如何处理这类问题,所以我来了 好的,我会把我的截图发给你。我的两个表是使用Javascript生成的,一个是静态的,我没有注释ListModulesWithInSene表中的tbody标记 (单击链接以查看图像) 这是我的HTML代码的简化版本,供感兴趣的人参考。我对这个网站很陌生,尽管我确实是从搜索引擎(Google)那里潜入的 预期的结果是

如果已经有人问过这类问题,我表示歉意,但我已经仔细阅读了“相关问题”,我认为这里的任何内容都与我的不匹配,所以请耐心等待,因为我试图提出我的问题,以及我将如何处理这类问题,所以我来了

好的,我会把我的截图发给你。我的两个表是使用Javascript生成的,一个是静态的,我没有注释ListModulesWithInSene表中的tbody标记

(单击链接以查看图像)

这是我的HTML代码的简化版本,供感兴趣的人参考。我对这个网站很陌生,尽管我确实是从搜索引擎(Google)那里潜入的

预期的结果是,我希望看到警报消息框,以确保它在调用代码生成数据行之前正常工作,例如

function ListAllModulesWithinScene(sceneName)
{
    /*listModulesWithinScene = document.getElementById("listModulesWithinScene");

    // Delete the tbody tag if it does not exist and create a enw tbody tag.
    if(listModulesWithinScene.getElementsByTagName("tbody") != null)
        listModulesWithinScene.removeChild("tbody");
    var listModulesWithinScene_tBody = document.createElement("tbody");

    var xmlRows = xmlObj.childNodes[2].getElementsByTagName("Scene");

    for (var r = 0; r < xmlRows.length; r++)
    {
        if (xmlRows[r].getAttribute("name") == sceneName)
        {
            var moduleRow = xmlRows[r].getElementsByTagName("Module");
            if (moduleRow.length > 0)
            {
                var row = document.createElement("tr");
                for (var msr = 0; msr < moduleRow.length; msr++)
                {
                    var moduleRow2 = xmlObj.childNodes[1].getElementsByTagName("Module");
                    for (var mr = 0; mr < xmlRow2.length; mr++)
                    {
                        if (moduleRow[mr].getAttribute("id") ==
                            xmlObj.childNodes[1].childNodes[mr].getAttribute("id"))
                        {
                            var td_id = document.createElement("th");
                            td_id.appendChild(
                                document.createTextNode(moduleRow.getAttribute("id")));
                            td_id.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_id");
                            row.appendChild(td_id);

                            var td_name = document.createElement("td");
                            td_name.appendChild(
                                document.createTextNode(moduleRow2.getAttribute("name")));
                            td_name.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_name");
                            row.appendChild(td_name);

                            var td_level = document.createElement("td");
                            td_level.appendChild(
                                document.createTextNode(moduleRow.getAttribute("level")));
                            td_level.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_level");
                            row.appendChild(td_level);
                        }
                    }
                }
            }
        }
    }
    listModulesWithinScene_tBody.appendChild(row);
    listModulesWithinScene.appendChild(listModulesWithinScene_tBody);*/
}
函数列表AllModulesWithInScene(场景名称)
{
/*listModulesWithinScene=document.getElementById(“listModulesWithinScene”);
//如果tbody标记不存在,请删除该标记,并创建一个enw tbody标记。
if(listModulesWithinScene.getElementsByTagName(“tbody”)!=null)
ListModulesWithinse.removeChild(“tbody”);
var listModulesWithinScene_tBody=document.createElement(“tBody”);
var xmlRows=xmlObj.childNodes[2].getElementsByTagName(“场景”);
for(var r=0;r0)
{
var行=document.createElement(“tr”);
对于(var msr=0;msr
为了更好地了解我的表是如何生成的,我想发布我的全部代码。我可以提供更多关于我的问题的细节,但现在我只能提供这些

这是我目前拥有的XMLReaderWriter.js文件

/* 在加载和保存XML文件时,尽量保持XML文件的组织性是有帮助的 而且格式良好,因此最好不要修改XML文件,除非您知道自己在做什么

XML文件的结构如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<HomeAutomationInterface>
<Setup>
<Location longitude="" latitude="" />
</Setup>
<Modules>
<!-- The first row is an example. -->
<Module id="1" name="module name" level="ON" type="dimmer">
<!-- ... -->
</Modules>
<Scenes>
<!-- the first row is an example. It can contain multiple modules. -->
<scene name="Scene Name">
<module id="1" level="50">
<module id="2" level="60">
<!-- ... -->
</scene>
<!-- ... -->
</Scenes>
<Timers>
<!-- The following four rows are an example. For DST, sunrise and sunset
is dependent in longitude and latitude. How this works is this:

1. Go to this website and enter your address information.
http://stevemorse.org/jcal/latlon.php

2. Go here and enter your today's date, followed by longitude and latitude,
and time zone: http://www.weatherimages.org/latlonsun.html

3. You should get your information related to sunrise and sunset. It should
look like this:

Thursday 
10 March 2011         Universal Time - 5h            

SUN
Begin civil twilight      06:30                 
Sunrise                   06:54                 
Sun transit               12:48                 
Sunset                    18:42                 
End civil twilight        19:06

Now that's how you get your times for your sunruse and sunset.
-->
<timer name="Timer Name 1" type="regular">
<regular time="hour:minute:second:millisecond">
<module id="1" level="50">
<!-- ... -->
</regular>
</timer>
<timer name="Timer Name 2" type="regular">
<regular time="hour:minute:second:millisecond">
<scene name="Scene Name">
<!-- ... -->
</regular>
</timer>
<timer name="Timer Name 3" type="DST">
<DST occour="sunrise|sunset" offsetDir="later|sooner"
offset="hour:minute:second:millisecond">
<module id="1" level="75">
<!-- ... -->
</DST>
</timer>
<timer name="Timer Name 4" type="DST">
<DST occour="sunrise|sunset" offsetDir="later|sooner"
offset="hour:minute:second:millisecond">
<scene name="Scene Name">
<!-- ... -->
</DST>
</timer>
<!-- ... -->
</Timers>
</HomeAutomationInterface>

It's a long documentation, but it helps to understand what this XML structure is all about.
*/

// Not for Internet Explorer 6 or below.
var xmlDoc;
var xmlObj;

// For HTML tables (<table>)
var listModules;
var listScenes;
var listModulesWithinScene;

// For HTML text boxes
var inputLongitude;
var inputLatitude;

function LoadXML()
{
    // ActiveXObject will have to be checked first to see if it's defined. Otherwise, if you
    // try to check XMLHttpRequest first, even if Internet Explorer supports it, you will get
    // "Access Denied" in Internet Explorer and perhaps not in Firefox.
    if (window.ActiveXObject)
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.load("HomeAutomationInterface.xml");
        PopulateFromXML();
    }
    else
    {
        // If this is the only code in this function, then you will need to put all your
        // project in the server, since Internet Explorer has a "Same Origin Policy" which
        // I believe that the open method with "GET" causes a problem in Internet Explorer
        // but did not cause a problem in Firefox. In order to rectify the problem, the code
        // inside if(window.ActiveXObject) makes use of ActiveX.
        xmlDoc = new XMLHttpRequest();
        xmlDoc.open("GET", "HomeAutomationInterface.xml", null)
        xmlDoc.send(null);
        if (xmlDoc.status == 200)
        {
            xmlDoc = xmlDoc.responseXML;
            PopulateFromXML();
        }
    }
}

function PopulateFromXML()
{
    listModules = document.getElementById(
        "listModules").getElementsByTagName("tbody");

    // Gather the text fields for location data.
    inputLongitude = document.getElementById("inputLongitude")
    inputLatitude = document.getElementById("inputLatitude")

    // Firefox's DOM Parser treats whitespaces as text nodes, including
    // line breaks.
    removeWhitespace(xmlDoc.documentElement);

    // Send the document's root element to the XML Object variable.
    xmlObj = xmlDoc.documentElement;

    // Perform the checks and populate the tables
    // and any other elements that are needed.
    if (xmlObj.tagName == "HomeAutomationInterface")
    {
        // Check to be sure the first node is the "Setup" node. It contains the
        // location node.
        if ((xmlObj.childNodes[0].tagName == "Setup") &&
            (xmlObj.childNodes[0].childNodes[0].tagName == "Location"))
        {
            // Copy the data from one of the attributes to the respective text boxes.
            inputLongitude.value = xmlObj.childNodes[0]
                .childNodes[0].getAttribute("longitude");
            inputLatitude.value = xmlObj.childNodes[0]
                .childNodes[0].getAttribute("latitude");
        }
        // The second node within the root element is Modules node.
        // This will be implemented.
        if (xmlObj.childNodes[1].tagName == "Modules")
        {
            //TODO: Implement the XML-to-Table translation that gets info
            // about modules.
            listModules = document.getElementById("listModules");
            var listModules_tBody = document.createElement("tbody");
            var xmlRows = xmlObj.childNodes[1].getElementsByTagName("Module");

            for (var r = 0; r < xmlRows.length; r++)
            {
                var xmlRow = xmlRows[r];
                var row = document.createElement("tr");

                var td_id = document.createElement("th");
                td_id.appendChild(document.createTextNode(xmlRow.getAttribute("id")));
                td_id.setAttribute("id", "listModules_row" + r + "_id");
                row.appendChild(td_id);

                var td_name = document.createElement("td");
                td_name.appendChild(document.createTextNode(xmlRow.getAttribute("name")));
                td_name.setAttribute("id", "listModules_row" + r + "_name");
                row.appendChild(td_name);

                var td_level = document.createElement("td");
                td_level.appendChild(document.createTextNode(xmlRow.getAttribute("level")));
                td_level.setAttribute("id", "listModules_row" + r + "_level");
                row.appendChild(td_level);

                if (xmlRow.getAttribute("type") == "dimmer")
                {
                    row.style.color = "Green";

                    // Create a new table cell for a dimmer. This will include a toggle,
                    // a text box, and a set button.
                    var td_dimmer = document.createElement("td");

                    // Create a new anchor tag and, set the href to #, and name it "Toggle."
                    var a_toggle = document.createElement("a");
                    a_toggle.href = "#";
                    a_toggle.id = "listMoudles_row" + r + "_dimmer_toggle";
                    a_toggle.appendChild(document.createTextNode("Toggle"));

                    td_dimmer.appendChild(a_toggle);

                    // Create a new div element to hold a text box and a set button.
                    var div_floatright = document.createElement("div");
                    div_floatright.style.float = "right";

                    // Create a new text box and append it to the div element.
                    var input_level = document.createElement("input");
                    input_level.type = "text";
                    input_level.name = "listModules_row" + r + "_inputLevel";
                    input_level.id = "listModules_row" + r + "_inputLevel";
                    input_level.style.width = "40px";

                    div_floatright.appendChild(input_level);

                    // Create a new anchor tag, set the href to #, and name it "Set."
                    var a_set = document.createElement("a");
                    a_set.href = "#";
                    a_set.id = "listMoudles_row" + r + "_dimmer_set";
                    a_set.appendChild(document.createTextNode("Set"));

                    div_floatright.appendChild(a_set);

                    // Append the div element to the table cell.
                    td_dimmer.appendChild(div_floatright);

                    // Finally, append the table cell to the row.
                    row.appendChild(td_dimmer);
                }
                else if (xmlRow.getAttribute("type") == "switch")
                {
                    row.style.color = "Blue";

                    // Create a new table cell for a dimmer. This will include a toggle,
                    // a text box, and a set button.
                    var td_switch = document.createElement("td");

                    // Create a new anchor tag and, set the href to #, and name it "Toggle."
                    var a_toggle = document.createElement("a");
                    a_toggle.href = "#";
                    a_toggle.id = "listMoudles_row" + r + "_dimmer_toggle";
                    a_toggle.appendChild(document.createTextNode("Toggle"));

                    td_switch.appendChild(a_toggle);

                    row.appendChild(td_switch);
                }
                else
                {
                    row.style.color = "Black";
                    row.appendChild(document.createTextNode("No actions available."));
                }

                listModules_tBody.appendChild(row);
            }
            listModules.appendChild(listModules_tBody);

            // Uncomment this code and run the example.
            //alert(listModules_row0_name.textContent);
        }
        // The third node within the root element is Scenes node.
        // You need modules in order for scenes to work.
        // This will be implemented.
        if (xmlObj.childNodes[2].tagName == "Scenes")
        {
            listScenes = document.getElementById("listScenes");
            var listScenes_tBody = document.createElement("tbody");
            var xmlRows = xmlObj.childNodes[2].getElementsByTagName("Scene");

            for (var r = 0; r < xmlRows.length; r++)
            {
                var xmlRow = xmlRows[r];
                var row = document.createElement("tr");

                var td_name = document.createElement("td");
                td_name.appendChild(document.createTextNode(xmlRow.getAttribute("name")));
                td_name.setAttribute("id", "listScenes_row" + r + "_name");
                row.appendChild(td_name);

                row.appendChild(td_name);

                var td_actions = document.createElement("td");

                // Create a new anchor tag and name it "Toggle."
                var a_toggle = document.createElement("a");
                a_toggle.href = "#";
                a_toggle.id = "listScenes_row" + r + "_toggle";
                a_toggle.appendChild(document.createTextNode("Toggle"));

                // Create a new anchor tag and name it "List."
                var a_set = document.createElement("a");
                a_set.href = "javascript:ListAllModulesWithinScene(listScenes_row" + r +
                    "_toggle";
                a_set.id = "listScenes_row" + r + "_set";
                a_set.appendChild(document.createTextNode("List"));

                td_actions.appendChild(a_toggle);
                td_actions.appendChild(a_set);

                row.appendChild(td_actions);

                listScenes_tBody.appendChild(row);
            }
            listScenes.appendChild(listScenes_tBody);
        }
        // The last element is the Timers node.
        // This will either activate the scene or turn on, off,
        // dim, brighten, or set the light level of the module if
        // it is the light module or turn on or off the appliance
        // module. This will be implemented.
        if (xmlObj.childNodes[3].tagName == "Timers")
        {
            //TODO: Implement a XML-to-Table parser that parses the XML data
            //      from the timers tag into the timer table.
        }
    }
}

// I stumbled across http://www.agavegroup.com/?p=32 and I borrowed the code from
// http://stackoverflow.com/questions/2792951/firefox-domparser-problem
// It took me a week to debug all my code until I find out what's going on with Firefox's
// DOM Inspector.
function removeWhitespace(node)
{
    for (var i = node.childNodes.length; i-- > 0; )
    {
        var child = node.childNodes[i];
        if (child.nodeType === 3 && child.data.match(/^\s*$/))
            node.removeChild(child);
        if (child.nodeType === 1)
            removeWhitespace(child);
    }
}

这是一个很长的文档,但它有助于理解XML结构的全部内容。
*/
//不适用于Internet Explorer 6或更低版本。
var-xmlDoc;
var-xmlObj;
//对于HTML表()
var模块;
虚拟现实场景;
var ListModules与InScene;
//用于HTML文本框
var输入经度;
输入纬度;
函数LoadXML()
{
//必须首先检查ActiveXObject是否已定义
//尝试先检查XMLHttpRequest,即使InternetExplorer支持它,您也会得到
//Internet Explorer中的“访问被拒绝”,可能Firefox中没有。
if(window.ActiveXObject)
{
xmlDoc=新的ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.async=false;
load(“HomeAutomationInterface.xml”);
PopulateFromXML();
}
其他的
{
//如果这是此函数中的唯一代码,那么您需要将所有
//项目,因为Internet Explorer具有“同源策略”,该策略
//我相信带有“GET”的open方法会在internetexplorer中引起问题
//但是在Firefox中没有引起问题。为了纠正问题,代码
//内部if(window.ActiveXObject)使用ActiveX。
xmlDoc=新的XMLHttpRequest();
open(“GET”,“HomeAutomationInterface.xml”,null)
xmlDoc.send(空);
如果(xmlDoc.status==200)
{
xmlDoc=xmlDoc.responseXML;
PopulateFromXML();
}
}
}
函数PopulateFromXML()
{
listModules=document.getElementById(
“listModules”).getElementsByTagName(“tbody”);
//收集位置数据的文本字段。
inputLongitude=document.getElementById(“inputLongitude”)
inputLatitude=document.getElementById(“inputLatitude”)
//Firefox的DOM解析器将空格视为文本节点,包括
//换行。
删除空白(xmlDoc.documentElemen)
function ListAllModulesWithinScene(sceneName)
{alert("test");
    /* The part of the code that I took out fills up the table with the list of modules
        that are part of the scene, each module having different levels/settings. */
}
function ListAllModulesWithinScene(sceneName)
{
    /*listModulesWithinScene = document.getElementById("listModulesWithinScene");

    // Delete the tbody tag if it does not exist and create a enw tbody tag.
    if(listModulesWithinScene.getElementsByTagName("tbody") != null)
        listModulesWithinScene.removeChild("tbody");
    var listModulesWithinScene_tBody = document.createElement("tbody");

    var xmlRows = xmlObj.childNodes[2].getElementsByTagName("Scene");

    for (var r = 0; r < xmlRows.length; r++)
    {
        if (xmlRows[r].getAttribute("name") == sceneName)
        {
            var moduleRow = xmlRows[r].getElementsByTagName("Module");
            if (moduleRow.length > 0)
            {
                var row = document.createElement("tr");
                for (var msr = 0; msr < moduleRow.length; msr++)
                {
                    var moduleRow2 = xmlObj.childNodes[1].getElementsByTagName("Module");
                    for (var mr = 0; mr < xmlRow2.length; mr++)
                    {
                        if (moduleRow[mr].getAttribute("id") ==
                            xmlObj.childNodes[1].childNodes[mr].getAttribute("id"))
                        {
                            var td_id = document.createElement("th");
                            td_id.appendChild(
                                document.createTextNode(moduleRow.getAttribute("id")));
                            td_id.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_id");
                            row.appendChild(td_id);

                            var td_name = document.createElement("td");
                            td_name.appendChild(
                                document.createTextNode(moduleRow2.getAttribute("name")));
                            td_name.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_name");
                            row.appendChild(td_name);

                            var td_level = document.createElement("td");
                            td_level.appendChild(
                                document.createTextNode(moduleRow.getAttribute("level")));
                            td_level.setAttribute("id", "listModulesFromScene_row" + r + 
                                "_level");
                            row.appendChild(td_level);
                        }
                    }
                }
            }
        }
    }
    listModulesWithinScene_tBody.appendChild(row);
    listModulesWithinScene.appendChild(listModulesWithinScene_tBody);*/
}
<?xml version="1.0" encoding="utf-8" ?>
<HomeAutomationInterface>
<Setup>
<Location longitude="" latitude="" />
</Setup>
<Modules>
<!-- The first row is an example. -->
<Module id="1" name="module name" level="ON" type="dimmer">
<!-- ... -->
</Modules>
<Scenes>
<!-- the first row is an example. It can contain multiple modules. -->
<scene name="Scene Name">
<module id="1" level="50">
<module id="2" level="60">
<!-- ... -->
</scene>
<!-- ... -->
</Scenes>
<Timers>
<!-- The following four rows are an example. For DST, sunrise and sunset
is dependent in longitude and latitude. How this works is this:

1. Go to this website and enter your address information.
http://stevemorse.org/jcal/latlon.php

2. Go here and enter your today's date, followed by longitude and latitude,
and time zone: http://www.weatherimages.org/latlonsun.html

3. You should get your information related to sunrise and sunset. It should
look like this:

Thursday 
10 March 2011         Universal Time - 5h            

SUN
Begin civil twilight      06:30                 
Sunrise                   06:54                 
Sun transit               12:48                 
Sunset                    18:42                 
End civil twilight        19:06

Now that's how you get your times for your sunruse and sunset.
-->
<timer name="Timer Name 1" type="regular">
<regular time="hour:minute:second:millisecond">
<module id="1" level="50">
<!-- ... -->
</regular>
</timer>
<timer name="Timer Name 2" type="regular">
<regular time="hour:minute:second:millisecond">
<scene name="Scene Name">
<!-- ... -->
</regular>
</timer>
<timer name="Timer Name 3" type="DST">
<DST occour="sunrise|sunset" offsetDir="later|sooner"
offset="hour:minute:second:millisecond">
<module id="1" level="75">
<!-- ... -->
</DST>
</timer>
<timer name="Timer Name 4" type="DST">
<DST occour="sunrise|sunset" offsetDir="later|sooner"
offset="hour:minute:second:millisecond">
<scene name="Scene Name">
<!-- ... -->
</DST>
</timer>
<!-- ... -->
</Timers>
</HomeAutomationInterface>

It's a long documentation, but it helps to understand what this XML structure is all about.
*/

// Not for Internet Explorer 6 or below.
var xmlDoc;
var xmlObj;

// For HTML tables (<table>)
var listModules;
var listScenes;
var listModulesWithinScene;

// For HTML text boxes
var inputLongitude;
var inputLatitude;

function LoadXML()
{
    // ActiveXObject will have to be checked first to see if it's defined. Otherwise, if you
    // try to check XMLHttpRequest first, even if Internet Explorer supports it, you will get
    // "Access Denied" in Internet Explorer and perhaps not in Firefox.
    if (window.ActiveXObject)
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.load("HomeAutomationInterface.xml");
        PopulateFromXML();
    }
    else
    {
        // If this is the only code in this function, then you will need to put all your
        // project in the server, since Internet Explorer has a "Same Origin Policy" which
        // I believe that the open method with "GET" causes a problem in Internet Explorer
        // but did not cause a problem in Firefox. In order to rectify the problem, the code
        // inside if(window.ActiveXObject) makes use of ActiveX.
        xmlDoc = new XMLHttpRequest();
        xmlDoc.open("GET", "HomeAutomationInterface.xml", null)
        xmlDoc.send(null);
        if (xmlDoc.status == 200)
        {
            xmlDoc = xmlDoc.responseXML;
            PopulateFromXML();
        }
    }
}

function PopulateFromXML()
{
    listModules = document.getElementById(
        "listModules").getElementsByTagName("tbody");

    // Gather the text fields for location data.
    inputLongitude = document.getElementById("inputLongitude")
    inputLatitude = document.getElementById("inputLatitude")

    // Firefox's DOM Parser treats whitespaces as text nodes, including
    // line breaks.
    removeWhitespace(xmlDoc.documentElement);

    // Send the document's root element to the XML Object variable.
    xmlObj = xmlDoc.documentElement;

    // Perform the checks and populate the tables
    // and any other elements that are needed.
    if (xmlObj.tagName == "HomeAutomationInterface")
    {
        // Check to be sure the first node is the "Setup" node. It contains the
        // location node.
        if ((xmlObj.childNodes[0].tagName == "Setup") &&
            (xmlObj.childNodes[0].childNodes[0].tagName == "Location"))
        {
            // Copy the data from one of the attributes to the respective text boxes.
            inputLongitude.value = xmlObj.childNodes[0]
                .childNodes[0].getAttribute("longitude");
            inputLatitude.value = xmlObj.childNodes[0]
                .childNodes[0].getAttribute("latitude");
        }
        // The second node within the root element is Modules node.
        // This will be implemented.
        if (xmlObj.childNodes[1].tagName == "Modules")
        {
            //TODO: Implement the XML-to-Table translation that gets info
            // about modules.
            listModules = document.getElementById("listModules");
            var listModules_tBody = document.createElement("tbody");
            var xmlRows = xmlObj.childNodes[1].getElementsByTagName("Module");

            for (var r = 0; r < xmlRows.length; r++)
            {
                var xmlRow = xmlRows[r];
                var row = document.createElement("tr");

                var td_id = document.createElement("th");
                td_id.appendChild(document.createTextNode(xmlRow.getAttribute("id")));
                td_id.setAttribute("id", "listModules_row" + r + "_id");
                row.appendChild(td_id);

                var td_name = document.createElement("td");
                td_name.appendChild(document.createTextNode(xmlRow.getAttribute("name")));
                td_name.setAttribute("id", "listModules_row" + r + "_name");
                row.appendChild(td_name);

                var td_level = document.createElement("td");
                td_level.appendChild(document.createTextNode(xmlRow.getAttribute("level")));
                td_level.setAttribute("id", "listModules_row" + r + "_level");
                row.appendChild(td_level);

                if (xmlRow.getAttribute("type") == "dimmer")
                {
                    row.style.color = "Green";

                    // Create a new table cell for a dimmer. This will include a toggle,
                    // a text box, and a set button.
                    var td_dimmer = document.createElement("td");

                    // Create a new anchor tag and, set the href to #, and name it "Toggle."
                    var a_toggle = document.createElement("a");
                    a_toggle.href = "#";
                    a_toggle.id = "listMoudles_row" + r + "_dimmer_toggle";
                    a_toggle.appendChild(document.createTextNode("Toggle"));

                    td_dimmer.appendChild(a_toggle);

                    // Create a new div element to hold a text box and a set button.
                    var div_floatright = document.createElement("div");
                    div_floatright.style.float = "right";

                    // Create a new text box and append it to the div element.
                    var input_level = document.createElement("input");
                    input_level.type = "text";
                    input_level.name = "listModules_row" + r + "_inputLevel";
                    input_level.id = "listModules_row" + r + "_inputLevel";
                    input_level.style.width = "40px";

                    div_floatright.appendChild(input_level);

                    // Create a new anchor tag, set the href to #, and name it "Set."
                    var a_set = document.createElement("a");
                    a_set.href = "#";
                    a_set.id = "listMoudles_row" + r + "_dimmer_set";
                    a_set.appendChild(document.createTextNode("Set"));

                    div_floatright.appendChild(a_set);

                    // Append the div element to the table cell.
                    td_dimmer.appendChild(div_floatright);

                    // Finally, append the table cell to the row.
                    row.appendChild(td_dimmer);
                }
                else if (xmlRow.getAttribute("type") == "switch")
                {
                    row.style.color = "Blue";

                    // Create a new table cell for a dimmer. This will include a toggle,
                    // a text box, and a set button.
                    var td_switch = document.createElement("td");

                    // Create a new anchor tag and, set the href to #, and name it "Toggle."
                    var a_toggle = document.createElement("a");
                    a_toggle.href = "#";
                    a_toggle.id = "listMoudles_row" + r + "_dimmer_toggle";
                    a_toggle.appendChild(document.createTextNode("Toggle"));

                    td_switch.appendChild(a_toggle);

                    row.appendChild(td_switch);
                }
                else
                {
                    row.style.color = "Black";
                    row.appendChild(document.createTextNode("No actions available."));
                }

                listModules_tBody.appendChild(row);
            }
            listModules.appendChild(listModules_tBody);

            // Uncomment this code and run the example.
            //alert(listModules_row0_name.textContent);
        }
        // The third node within the root element is Scenes node.
        // You need modules in order for scenes to work.
        // This will be implemented.
        if (xmlObj.childNodes[2].tagName == "Scenes")
        {
            listScenes = document.getElementById("listScenes");
            var listScenes_tBody = document.createElement("tbody");
            var xmlRows = xmlObj.childNodes[2].getElementsByTagName("Scene");

            for (var r = 0; r < xmlRows.length; r++)
            {
                var xmlRow = xmlRows[r];
                var row = document.createElement("tr");

                var td_name = document.createElement("td");
                td_name.appendChild(document.createTextNode(xmlRow.getAttribute("name")));
                td_name.setAttribute("id", "listScenes_row" + r + "_name");
                row.appendChild(td_name);

                row.appendChild(td_name);

                var td_actions = document.createElement("td");

                // Create a new anchor tag and name it "Toggle."
                var a_toggle = document.createElement("a");
                a_toggle.href = "#";
                a_toggle.id = "listScenes_row" + r + "_toggle";
                a_toggle.appendChild(document.createTextNode("Toggle"));

                // Create a new anchor tag and name it "List."
                var a_set = document.createElement("a");
                a_set.href = "javascript:ListAllModulesWithinScene(listScenes_row" + r +
                    "_toggle";
                a_set.id = "listScenes_row" + r + "_set";
                a_set.appendChild(document.createTextNode("List"));

                td_actions.appendChild(a_toggle);
                td_actions.appendChild(a_set);

                row.appendChild(td_actions);

                listScenes_tBody.appendChild(row);
            }
            listScenes.appendChild(listScenes_tBody);
        }
        // The last element is the Timers node.
        // This will either activate the scene or turn on, off,
        // dim, brighten, or set the light level of the module if
        // it is the light module or turn on or off the appliance
        // module. This will be implemented.
        if (xmlObj.childNodes[3].tagName == "Timers")
        {
            //TODO: Implement a XML-to-Table parser that parses the XML data
            //      from the timers tag into the timer table.
        }
    }
}

// I stumbled across http://www.agavegroup.com/?p=32 and I borrowed the code from
// http://stackoverflow.com/questions/2792951/firefox-domparser-problem
// It took me a week to debug all my code until I find out what's going on with Firefox's
// DOM Inspector.
function removeWhitespace(node)
{
    for (var i = node.childNodes.length; i-- > 0; )
    {
        var child = node.childNodes[i];
        if (child.nodeType === 3 && child.data.match(/^\s*$/))
            node.removeChild(child);
        if (child.nodeType === 1)
            removeWhitespace(child);
    }
}
a_set.href = "javascript:ListAllModulesWithinScene(listScenes_row"
           + r + "_toggle)";//<br />
a_set.href = "javascript:ListAllModulesWithinScene(\"listScenes_row" + r + "_toggle\")";