Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape and reading external XML values

    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
    Last edited by evbase; 12-04-2002 at 02:24 AM.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •