Using XML in netscape

A

Amit

Hi,
I have the following javascript code in my ASP.net page which I am
using to read and parse XML from my server in order to create a
javascript based menu. However, I have observed that the Netscape
browser hangs if I refresh the page using Ctrl-R or F5 but works fine
if I navigate to other pages. I have identified the problem to be
occurring in the lines of code where we create a document object and
read XML . Here's the code for your reference:

xmlDoc=document.implementation.createDocument("","",null);


xmlDoc.async=false;
xmlDoc.load("Menu.xml");


var nodes = xmlDoc.getElementsByTagName("record");


and here's the XML used:


<Root>
<record>
<MenuNumber>1</MenuNumber>
<TextToShow>Master Maintenance</TextToShow>
<Link>javascript:blankLink()</Link>
<NumberOfSubElements>9</NumberOfSubElements>
</record>
</Root>


In IE, I am using the following code to parse the xml which works
fine
even on refresh


var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";


xmlDoc.load("../Scripts/MenuScripts/Menu.xml");


In Netscape, is there any other way of reading and parsing the xml
document instead of using document.implementation.createDocument ?
 
R

Richard Cornford

Amit said:
I have the following javascript code in my ASP.net page which I am
using to read and parse XML from my server in order to create a
javascript based menu. However, I have observed that the Netscape
browser hangs if I refresh the page using Ctrl-R or F5 but works fine
if I navigate to other pages. I have identified the problem to be
occurring in the lines of code where we create a document object and
read XML . Here's the code for your reference:

xmlDoc=document.implementation.createDocument("","",null);

xmlDoc.async=false;
xmlDoc.load("Menu.xml");

var nodes = xmlDoc.getElementsByTagName("record");

and here's the XML used:

<Root>
<record>
<MenuNumber>1</MenuNumber>
<TextToShow>Master Maintenance</TextToShow>
<Link>javascript:blankLink()</Link>
<NumberOfSubElements>9</NumberOfSubElements>
</record>
</Root>

In IE, I am using the following code to parse the xml which works
fine even on refresh

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";

xmlDoc.load("../Scripts/MenuScripts/Menu.xml");

In Netscape, is there any other way of reading and parsing the xml
document instead of using document.implementation.createDocument ?

If you want to read an XML file into a web browser and end up with an
XML DOM what is wrong with using an XML HTTP request object?

Why is the path you are using for the IE version different form the path
you are using in the Netscape version? Maybe the act of reloading in
Netscape is throwing the base URL off and subsequently the relative URLs
are not being resolved as the same path. Have you monitored the network
traffic from the browser to see if Netscape is actually making the
requests, and if so what the absolute URLs used and responses are?

Is that a javascript pseudo-protocol URL I see in your XML Link element?
You do realise that if you execute a javascript pseudo-protocol URL in a
web browser all bets are off as to what will or will not work
subsequently (though its IE < 7 that suffers most from that phenomenon
so probably not a cause of a Netscape issue (assuming it is using the
Gecko engine for this page rather than its embedded IE)?

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top