473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

XML Parsing Problem in Internet Explorer

I seem to be getting this weird problem in Internet explorer. I have
written a code for parsing a XML file and displaying the output. The
code works perfectly fine with ffx(Firefox).However is not working in
Internet Explorer.(I m using Internet Explorer 6.0). The code is as
follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
djConfig="parseOnLoad:true">
</script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.TitlePane");
</script>
<style type="text/css">
@import "dojo-release-1.1.1/dojo/resources/dojo.css";
@import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
#output
{
width:500px;
}
</style>
<script language="javascript">
function create_button(titletoapply,idtoapply,cont)
{
ttltoapply = titletoapply;
ids = idtoapply;
conti = cont;
elementcreator(ids,conti);
var params = {

// Note here, when creating programmatically,
this is a function, not a string
open:false,
title:ttltoapply
};

var button_dynamic = new dijit.TitlePane(
params,dojo.byId(ids)
);
}
function elementcreator(id,content)
{
var idtoassign = id;
var contenttoassign = content;
var browser = navigator.userAgent;
if(browser.indexOf("MSIE") != -1)
{
var diselement = document.createElement('div');
var diselementattrib = document.createAttribute('id');
diselementattrib.value = idtoassign;
diselement.setAttributeNode(diselementattrib);
diselement.innerHTML = contenttoassign;

var core = document.getElementById('output');
core.appendChild(diselement);
}
else
{
var elem = document.createElement('div');
elem.setAttribute('id',idtoassign);
elem.innerHTML = contenttoassign;
var core = document.getElementById('output');
core.appendChild(elem);
}
}
function createXHR()
{
try{return new XMLHttpRequest();}catch(e){}
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
}
function sendrequest()
{
var xhr = createXHR();
xhr.open("GET","Example1.xml",true);
xhr.onreadystatechange = function(){handleresponse(xhr);}
xhr.send(null);
}
function handleresponse(xhr)
{
var response = xhr.responseXML;
var rssentries=response.getElementsByTagName("item");
var linku;
var title;
var idgenerated;
for (var i=0; i<rssentries.length; i++){
idgenerated = "count" + i;
linku=rssentries[i].getElementsByTagName('link')
[0].firstChild.nodeValue;
title=rssentries[i].getElementsByTagName('title')
[0].firstChild.nodeValue;
//create_button(title,idgenerated,linku);
elementcreator(idgenerated,title);
}

var display = document.getElementById('output');
//display.innerHTML = output;
}
function closetabs()
{
var core=document.getElementById("bbdy");
var child=document.getElementById("output");
core.removeChild(child);
}
</script>
</head>

<body class="tundra" id="bbdy">
<div id="output"></div>
<button onclick="sendrequest()">Process</button>
<button onclick="closetabs()">remove</button>
</body>
</html>

P.S: The dojo part of the script can be commented as it has no
relation with the working of logic

The xml file for this is as follows

<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="0.91">
<channel>
<title>JavaScriptKit.com</title>
<link>http://www.javascriptkit.com</link>
<description>JavaScript tutorials and over 400+ free scripts!</
description>
<language>en</language>

<item>
<title>Document Text Resizer</title>
<link>http://www.javascriptkit.com/script/script2/
doctextresizer.shtml</link>
<description>This script adds the ability for your users to toggle
your webpage's font size, with persistent cookies then used to
remember the setting</description>
</item>

<item>
<title>JavaScript Reference- Keyboard/ Mouse Buttons Events</title>
<link>http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml</
link>
<description>The latest update to our JS Reference takes a hard look
at keyboard and mouse button events in JavaScript, including the
unicode value of each key.</description>
</item>

<item>
<title>Dynamically loading an external JavaScript or CSS file</title>
<link>http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml</
link>
<description>External JavaScript or CSS files do not always have to be
synchronously loaded as part of the page, but dynamically as well. In
this tutorial, see how.</description>
</item>

</channel>
</rss>

Please can anyone provide me solution for this prob
Oct 11 '08 #1
1 4786
av**********@gmail.com wrote:
I seem to be getting this weird problem in Internet explorer. I have
written a code for parsing a XML file and displaying the output. The
code works perfectly fine with ffx(Firefox).However is not working in
Internet Explorer.(I m using Internet Explorer 6.0).
Do you get any error with IE? If so which one, for which line?
function elementcreator(id,content)
{
var idtoassign = id;
var contenttoassign = content;
var browser = navigator.userAgent;
if(browser.indexOf("MSIE") != -1)
{
var diselement = document.createElement('div');
var diselementattrib = document.createAttribute('id');
diselementattrib.value = idtoassign;
diselement.setAttributeNode(diselementattrib);
diselement.innerHTML = contenttoassign;

var core = document.getElementById('output');
core.appendChild(diselement);
}
else
{
var elem = document.createElement('div');
elem.setAttribute('id',idtoassign);
elem.innerHTML = contenttoassign;
var core = document.getElementById('output');
core.appendChild(elem);
}
}
That can be shortened to

function elementcreator(id,content)
{
var diselement = document.createElement('div');
diselement.id = id;

diselement.innerHTML = content;

var core = document.getElementById('output');
core.appendChild(diselement);
}
function sendrequest()
{
var xhr = createXHR();
xhr.open("GET","Example1.xml",true);
xhr.onreadystatechange = function(){handleresponse(xhr);}
I think you want
xhr.onreadystatechange = function()
{
if (xhr.readyState === 4)
{
handleresponse(xhr);
}
};


--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 11 '08 #2

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

Similar topics

2
by: Raymond H. | last post by:
Hello, I create a vb4 project which can also naviger on Internet via the WebBrowser control which I put on my form. My question is: if this program is installed on a station having already...
2
by: CathieC | last post by:
I have a websote developed using visual studio 2005 beta , .net version 2 i deploy my application to a server and it is run from client computers. One of the users gets the error "Internet...
3
by: VK | last post by:
Internet Explorer 7 beta 2 preview CNET Editor review: <http://reviews.cnet.com/Internet_Explorer_7_for_XP_SP2_Beta_2/4505-3514_7-31454661-2.html?tag=nl.e415> Summary (my personal review...
11
by: Wendy | last post by:
Hello, I have a program that does the following: When a user clicks on a row in a VB.NET datagrid, it will open a web page in Internet Explorer (that corresponds to that item in the selected row...
3
by: laredotornado | last post by:
Hi, This problem only affects PC IE. On a secured page (a page visited via https), there is a link that reads -- "Download HTML File". The link connects to this page <?php...
1
by: danep | last post by:
Hi, I'm fairly new to AJAX, but I've been able to retrieve HTML and plain-text documents without any trouble. However, I haven't figured out how to retrieve it in XML format. Basically, here's...
9
by: Etayki | last post by:
Hi! I am new to VB.net and I am using the Visual Basic 2005 Express Edition I have two questions: 1. I am trying to write an application that will automate Internet Explorer and store data...
3
by: =?Utf-8?B?dHVtYQ==?= | last post by:
I have a XML file with following content. <?xml version="1.0"?> <devices version="1.0"> <device id="S60_3rd" name="com.nokia.s60" default="no" userdeletable="no">...
3
by: Ananthu | last post by:
Hi I have created one website named OTMS using ASP.NET in a File System Format.My project location is in F: drive(F:\Project\OTMS). I have installed IIS properly and the website runs properly in...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.