473,487 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

XML+HTML Code with sporadic results in construction

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);
}

Mar 8 '06 #1
3 1820
VK

ch******************@gmail.com wrote:
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.


Holly... Did you ever hear about XSLT? XPath?

data.xml :
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
....
and so on

Mar 8 '06 #2
yes i have heard of it VK, but at this time I do not understand it very
well. My approach would be to learn how to do it manually. Once this
works proceed to reimplement this with XSL and XPath.

Mar 8 '06 #3
After much debugging I have found the solution and felt it best to post
the solution, for other people to learn from.

//not working right
htmlLayout[htmlLayout.length] = "<h3><a
onclick=\'displayInformation(\"" +
nodeList.selectSingleNode('title').text
+ "\"" + ", " + "\"" +

nodeList.selectSingleNode('category').text + "\"" + "," +
"\"" + TabCatalog[j].pageName + "\"" +
");\'>" +
nodeList.selectSingleNode('title').text
+ "</a></h3>";

the single quote had to be implemented to allow the double quotes to
not bring up the issues of mistmatch string termination.

Mar 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1645
by: marboti | last post by:
http://www.testyourabilities.com/it/ IT tests. C, C++, XML, HTML, .NET, SQL...
0
979
by: marboti | last post by:
http://www.testyourabilities.com/it/ IT tests. SQL, XML, HTML, .NET, C++...
1
1274
by: marboti | last post by:
http://www.testyourabilities.com/it/ IT tests. C#, ASP.NET, VB.NET, SQL, XML, HTML, C, C++...
0
891
by: marboti | last post by:
http://www.testyourabilities.com/it/ IT tests. ASP.NET, C#, VB.NET, SQL, XML, HTML, C, C++...
0
789
by: marboti | last post by:
http://www.testyourabilities.com/it/ IT tests. VB.NET, C#, ASP.NET, SQL, XML, HTML, C, C++...
4
1963
by: Angus McPresley | last post by:
>From within a JSP, I need to hit another server to retrieve some XML results, then parse them programmatically. If I use a StreamResult object, I can transform the results I get back using XSL...
7
6885
by: doneirik | last post by:
Dear Group, I do not know any XML, however, I probably need to use it... Working on a plugin in Jira, I have an example opening a link using the "href" command. Instead of opening a link, I...
1
1620
by: kranthi gaddam | last post by:
how to create tree with xml code by c#.net?
5
7701
by: PatlaDJ | last post by:
Java SAX parser, please need a clue how to get the raw XML code of the currently parsing event... needed for logging, debugging purposes. Here's and example, letting me clarify exactly what i...
4
4552
by: shifflav | last post by:
The code below puts each item in a float:left DIV. After each 3rd DIV it needs to clear the previous 3 DIVs and start a new row. The code below works, but it requires that I edit a 'column' element...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.