473,581 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).Ho wever 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.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>
<script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
djConfig="parse OnLoad:true">
</script>
<script type="text/javascript">
dojo.require("d ojo.parser");
dojo.require("d ijit.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="javas cript">
function create_button(t itletoapply,idt oapply,cont)
{
ttltoapply = titletoapply;
ids = idtoapply;
conti = cont;
elementcreator( ids,conti);
var params = {

// Note here, when creating programmaticall y,
this is a function, not a string
open:false,
title:ttltoappl y
};

var button_dynamic = new dijit.TitlePane (
params,dojo.byI d(ids)
);
}
function elementcreator( id,content)
{
var idtoassign = id;
var contenttoassign = content;
var browser = navigator.userA gent;
if(browser.inde xOf("MSIE") != -1)
{
var diselement = document.create Element('div');
var diselementattri b = document.create Attribute('id') ;
diselementattri b.value = idtoassign;
diselement.setA ttributeNode(di selementattrib) ;
diselement.inne rHTML = contenttoassign ;

var core = document.getEle mentById('outpu t');
core.appendChil d(diselement);
}
else
{
var elem = document.create Element('div');
elem.setAttribu te('id',idtoass ign);
elem.innerHTML = contenttoassign ;
var core = document.getEle mentById('outpu t');
core.appendChil d(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.XMLHT TP");}catch(e){ }
}
function sendrequest()
{
var xhr = createXHR();
xhr.open("GET", "Example1.xml", true);
xhr.onreadystat echange = function(){hand leresponse(xhr) ;}
xhr.send(null);
}
function handleresponse( xhr)
{
var response = xhr.responseXML ;
var rssentries=resp onse.getElement sByTagName("ite m");
var linku;
var title;
var idgenerated;
for (var i=0; i<rssentries.le ngth; i++){
idgenerated = "count" + i;
linku=rssentrie s[i].getElementsByT agName('link')
[0].firstChild.nod eValue;
title=rssentrie s[i].getElementsByT agName('title')
[0].firstChild.nod eValue;
//create_button(t itle,idgenerate d,linku);
elementcreator( idgenerated,tit le);
}

var display = document.getEle mentById('outpu t');
//display.innerHT ML = output;
}
function closetabs()
{
var core=document.g etElementById(" bbdy");
var child=document. getElementById( "output");
core.removeChil d(child);
}
</script>
</head>

<body class="tundra" id="bbdy">
<div id="output"></div>
<button onclick="sendre quest()">Proces s</button>
<button onclick="closet abs()">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>JavaScri ptKit.com</title>
<link>http://www.javascriptk it.com</link>
<description>Ja vaScript tutorials and over 400+ free scripts!</
description>
<language>en</language>

<item>
<title>Docume nt Text Resizer</title>
<link>http://www.javascriptkit.com/script/script2/
doctextresizer. shtml</link>
<description>Th is 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>JavaScri pt Reference- Keyboard/ Mouse Buttons Events</title>
<link>http://www.javascriptk it.com/jsref/eventkeyboardmo use.shtml</
link>
<description>Th e 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>Dynamica lly loading an external JavaScript or CSS file</title>
<link>http://www.javascriptk it.com/javatutors/loadjavascriptc ss.shtml</
link>
<description>Ex ternal 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 4819
av**********@gm ail.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).Ho wever 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.userA gent;
if(browser.inde xOf("MSIE") != -1)
{
var diselement = document.create Element('div');
var diselementattri b = document.create Attribute('id') ;
diselementattri b.value = idtoassign;
diselement.setA ttributeNode(di selementattrib) ;
diselement.inne rHTML = contenttoassign ;

var core = document.getEle mentById('outpu t');
core.appendChil d(diselement);
}
else
{
var elem = document.create Element('div');
elem.setAttribu te('id',idtoass ign);
elem.innerHTML = contenttoassign ;
var core = document.getEle mentById('outpu t');
core.appendChil d(elem);
}
}
That can be shortened to

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

diselement.inne rHTML = content;

var core = document.getEle mentById('outpu t');
core.appendChil d(diselement);
}
function sendrequest()
{
var xhr = createXHR();
xhr.open("GET", "Example1.xml", true);
xhr.onreadystat echange = function(){hand leresponse(xhr) ;}
I think you want
xhr.onreadystat echange = 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
2669
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 Internet Explorer in it then will it cause an error if version Internet Explorer is the same one as WebBrowser which is in my project? Is it this control...
2
2286
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 Explorer cannot open the internet site "XXXXX" Operation aborted" this happens when they click on a menu item to open a page. they do not get
3
2338
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 interpretation): "Half stolen from Firefox, half is buggy - including the stolen part". Download:...
11
11604
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 in the datagrid). It will automatically print that web page, and then it will close the Internet Explorer window. I have code that works...
3
11484
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 require("../../util_fns.php"); session_start();
1
2070
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 the script that's supposed to retrieve and parse the data when you pass it the url of the page generating the XML data: <script...
9
7718
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 in a database. Am I better off learning VB.net or C#.net? Is there a free development environment for C# as well?
3
2142
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"> <epocroot>C:\Symbian\9.1\S60_3rd\</epocroot> </device> <device id="S60_3rd_FP1" name="com.nokia.s60" default="yes" userdeletable="no">...
3
10467
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 Internet Explorer as a File System Format. I have created a new virtual directory(OTMS) in IIS and i have included my website...
0
7792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8175
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5364
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3805
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
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 we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.