C
christopher.davidson
Hello,
I am working with XML files and utilizing Array functions to take the
XML data and combined it with some html code to display a particular
page.
The process currently works like so:
1.) Request an Async request of the XML
2.) Once complete, parse the appropriate XML data to parse
3.) Put the html code and xml data into an array for construction
4.) Once parsing is complete "finish" the array and display within an
innerHTML tag
When I try to do this I get very sporadic results.
1.) Data being out of order from XML to the construction
2.) Replacing " or ' with ? within the code.
Listed below is the code in question, there is a comment stating
//not working
The code is looped through depending on the number of Tabs within the
page, pushing certain data to each tab section. The first page will be
malformed, the second page will be ok, the third is a hit or miss.
The XML data is not being changed in any respect through out this whole
process.
Any guidance will be greatly appreciated
Thank you for your time.
function displayReports() {
var htmlLayout;
var xmlPull = new getHTTPObject();
var url = "code/reportCatalog.xml";
var obj;
if (document.implementation && document.implementation.createDocument)
{
obj = document.implementation.createDocument("", "", null);
obj.async = false;
} else {
obj = new ActiveXObject("Microsoft.XMLDOM");
obj.async = false;
}
xmlPull.open("GET", url, true);
xmlPull.onreadystatechange = function() {
if (xmlPull.readyState == 4) {
if (xmlPull.status == 200) {
if (window.ActiveXObject) {
obj.loadXML(xmlPull.responseText);
for (var j = 0; j < TabCatalog.length; j++) {
htmlLayout = new Array();
htmlLayout[htmlLayout.length] = "<div id=\"reportList\">";
var pageString = (TabCatalog[j].pageName).toUpperCase();
for (var i = 0; i < obj.documentElement.childNodes.length; i++) {
var nodeList =
obj.documentElement.getElementsByTagName('report').item(i);
if (pageString.substring(0, (pageString.length - 5)) ==
nodeList.selectSingleNode('category').text) {
//not working right
htmlLayout[htmlLayout.length] = "<h3><a
onclick=displayInformation(\"" +
nodeList.selectSingleNode('title').text + "\", \"" +
nodeList.selectSingleNode('category').text + "\")></a>"+
nodeList.selectSingleNode('title').text +
"</h3>";
//if the group tag exists within the report then add the group
description
if (nodeList.selectSingleNode('group')) {
htmlLayout[htmlLayout.length] = "Group: " +
nodeList.selectSingleNode('group').text + " <br/>";
}
htmlLayout[htmlLayout.length] = "<i>" +
nodeList.selectSingleNode('description').text +
"</i>";
htmlLayout[htmlLayout.length] = "Create Date:" +
nodeList.selectSingleNode('createdate').text +
"<br />";
}
}
htmlLayout[htmlLayout.length] = "</div>";
document.getElementById('panel_' +
TabCatalog[j].pageId).innerHTML = htmlLayout.join("");
//added for debugging purposes
alert(document.getElementById('panel_' +
TabCatalog[j].pageId).innerHTML);
}
}
}
delete htmlLayout, nodeList, pageString;
populatePreviewArea();
}
};
xmlPull.setRequestHeader("Content-Type", "text/xml; charset=UTF-16");
xmlPull.send(null);
}
I am working with XML files and utilizing Array functions to take the
XML data and combined it with some html code to display a particular
page.
The process currently works like so:
1.) Request an Async request of the XML
2.) Once complete, parse the appropriate XML data to parse
3.) Put the html code and xml data into an array for construction
4.) Once parsing is complete "finish" the array and display within an
innerHTML tag
When I try to do this I get very sporadic results.
1.) Data being out of order from XML to the construction
2.) Replacing " or ' with ? within the code.
Listed below is the code in question, there is a comment stating
//not working
The code is looped through depending on the number of Tabs within the
page, pushing certain data to each tab section. The first page will be
malformed, the second page will be ok, the third is a hit or miss.
The XML data is not being changed in any respect through out this whole
process.
Any guidance will be greatly appreciated
Thank you for your time.
function displayReports() {
var htmlLayout;
var xmlPull = new getHTTPObject();
var url = "code/reportCatalog.xml";
var obj;
if (document.implementation && document.implementation.createDocument)
{
obj = document.implementation.createDocument("", "", null);
obj.async = false;
} else {
obj = new ActiveXObject("Microsoft.XMLDOM");
obj.async = false;
}
xmlPull.open("GET", url, true);
xmlPull.onreadystatechange = function() {
if (xmlPull.readyState == 4) {
if (xmlPull.status == 200) {
if (window.ActiveXObject) {
obj.loadXML(xmlPull.responseText);
for (var j = 0; j < TabCatalog.length; j++) {
htmlLayout = new Array();
htmlLayout[htmlLayout.length] = "<div id=\"reportList\">";
var pageString = (TabCatalog[j].pageName).toUpperCase();
for (var i = 0; i < obj.documentElement.childNodes.length; i++) {
var nodeList =
obj.documentElement.getElementsByTagName('report').item(i);
if (pageString.substring(0, (pageString.length - 5)) ==
nodeList.selectSingleNode('category').text) {
//not working right
htmlLayout[htmlLayout.length] = "<h3><a
onclick=displayInformation(\"" +
nodeList.selectSingleNode('title').text + "\", \"" +
nodeList.selectSingleNode('category').text + "\")></a>"+
nodeList.selectSingleNode('title').text +
"</h3>";
//if the group tag exists within the report then add the group
description
if (nodeList.selectSingleNode('group')) {
htmlLayout[htmlLayout.length] = "Group: " +
nodeList.selectSingleNode('group').text + " <br/>";
}
htmlLayout[htmlLayout.length] = "<i>" +
nodeList.selectSingleNode('description').text +
"</i>";
htmlLayout[htmlLayout.length] = "Create Date:" +
nodeList.selectSingleNode('createdate').text +
"<br />";
}
}
htmlLayout[htmlLayout.length] = "</div>";
document.getElementById('panel_' +
TabCatalog[j].pageId).innerHTML = htmlLayout.join("");
//added for debugging purposes
alert(document.getElementById('panel_' +
TabCatalog[j].pageId).innerHTML);
}
}
}
delete htmlLayout, nodeList, pageString;
populatePreviewArea();
}
};
xmlPull.setRequestHeader("Content-Type", "text/xml; charset=UTF-16");
xmlPull.send(null);
}