...

View Full Version : Netscape and reading external XML values



evbase
12-04-2002, 02:17 AM
I'm trying to get this nice little script to work in Netscape 6+ and I think it's the script that's giving me fits...

What it does in IE:
1.
<xml> includer loads information from an external XML document into the page so that all the values are present.
2.
The script assigns ids to the information and loads that information into a formatted output table on the page on demand (the command being the user clicks on the cell of a "click-sensitive" table that contains the option they wish to choose.)

Like so ...

<script type="text/javascript">
<!--
function testclick(field)
{
var row=field.rowIndex
xmldso_list.recordset.absoluteposition=row
td_company.innerHTML=xmldso_list.recordset("COMPANY")
td_description.innerHTML=xmldso_list.recordset("DESCRIPTION")
td_address.innerHTML=xmldso_list.recordset("ADDRESS")
td_citystate.innerHTML=xmldso_list.recordset("CITYSTATE")
td_phone.innerHTML=xmldso_list.recordset("PHONE")
td_email.innerHTML=xmldso_list.recordset("EMAIL")
td_contact.innerHTML=xmldso_list.recordset("CONTACT")
td_website.innerHTML=xmldso_list.recordset("WEBSITE")
}
//-->
</script>


The script later gets called here ... (in a table | formatting truncated here ... original contains cells for all resulting values)

<td bgcolor="whitesmoke" id="td_address">Address:</td>
</tr>
<tr align="left">
<td bgcolor="whitesmoke" id="td_citystate">City/State:</td>
</tr>
<tr align="left">
<td bgcolor="whitesmoke" id="td_phone">Phone:</td>


Problem is that Netscape (*hisses heard in the background) won't parse the information the way the script is organized now. I am a designer first and foremost and though I pride myself on knowing a little bit more than average about coding/scripting...this one is admittedly beyond me. If this script is workable for NS that would be great. If it just can't be done, I'd be interested in alternatives if any are available. Any help here would be greatly appreciated.

EDIT: Since I'm not sure I'm explaining this correctly, here's an example page... obviously you're only going to see results in IE 4+.

http://www.evbase.com/xml/example.htm


Thanks in advance, all.

-evbase

jkd
12-04-2002, 02:51 AM
Unfortunately, you are using a proprietary element of Internet Explorer with this:
<xml id="xmldso_list" src="firm_listing.xml"></xml>

This is not the correct way to import nor use XML data.

The correct way is through pure scripting:

var doc = document.implementation.createDocument('', '', null);
doc.load('firm-listing.xml');
doc.addEventListener('load', function(event) {
// use DOM to parse doc, and insert nodes into the curent document
}, false);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum