Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2004, 02:30 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default XML and netscape / mozilla

I am using XML in web scripts to dynamically refresh portions of web pages. For e.g. If dynamically populating one select box depending on the value chosen from another select box. I am attaching a sample JS code I am using. The idea is to submit an xml to an ASP page. The ASP page processes it and returns an XML back. This reply XML is parsed with the help of Javascript to refresh portions of web page.

function func_retrieve_fabric_types()
        {
            var str_browser=func_get_browser();
            var str_xml="";
            //alert(document.frm_test.cbo_fabric_categories.opti ons[document.frm_test.cbo_fabric_categories.selectedIn dex].value);
            if(!((document.frm_test.cbo_fabric_categories.opti ons[document.frm_test.cbo_fabric_categories.selectedIn dex].value)==""))
            {
                str_xml+="<xml_to_be_submitted><request_xml><fabri c_cat_id>"+document.frm_test.cbo_fabric_categories .options[document.frm_test.cbo_fabric_categories.selectedIn dex].value+"</fabric_cat_id></request_xml></xml_to_be_submitted>";
                if(str_browser=="IE")
                {
                    var obj_http=new ActiveXObject("Microsoft.XMLHTTP");
                }
                else if(str_browser=="NS6")
                {
                    alert("browser is NS 6 or later");
                    var obj_http=new XMLRemoteRequest();
                }
                var str_url="testfb.asp";
                var str_http_method="post";
                obj_http.open(str_http_method,str_url,false);
                obj_http.SetRequestHeader("Content-Type","application/x-www-form-urlencoded");
                obj_http.send(str_xml);
                var str_reply=obj_http.ResponseText;

                //processes return xml
                alert (str_reply);
                var xmlResponse = str_reply;
                var objXmlDOM=new ActiveXObject("Microsoft.XMLDOM");
                if(!objXmlDOM.loadXML(xmlResponse))
                {
                    alert("Could not load xml object");
                }
                else
                {
                    var i_option_id = objXmlDOM.selectNodes("/options/option_id");
                    var str_option_text = objXmlDOM.selectNodes("/options/option_text");
                    var i_loop;
                    var i_num_options=1;
                    document.frm_test.cbo_fabric_types.options.length= 1;
                    for(i_loop=0;i_loop<i_option_id.length;++i_loop)
                    {
                        document.frm_test.cbo_fabric_types.options.length+ =1;
                        i_num_options++;
                        document.frm_test.cbo_fabric_types.options[i_num_options-1].value=i_option_id[i_loop].text;
                        document.frm_test.cbo_fabric_types.options[i_num_options-1].text=str_option_text[i_loop].text;
                    }
                }
            }
        }

I am not getting the response XML back from server when the browser is netscape is 6 or 7.

This code will work only in IE (so that I have to tell the clients to use IE alone to run the intra office applications). I would like to know whether there are any similar code / technique that will make it run on netscape / mozilla ?

Thanks for reading.
 
Old May 21st, 2004, 04:01 PM
Authorized User
 
Join Date: Nov 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sonicDace Send a message via MSN to sonicDace Send a message via Yahoo to sonicDace
Default

There are a couple of problems here:

I'm assuming you want your code to work in NE to ensure compatability with people who don't have IE. One shortcoming is that the XMLDOM parser ships with IE, so regardless of what browser they use, if they don't have IE, or any other app that ships with it, they won't be able to instantiate Microsoft.XMLDOM

I haven't tried in some time, but last time I needed to create a dom parser object in netscape, new ActiveXObject didn't work, and I had to use something like:

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

I think it had to do with netscape not instantiating ActiveX Objects alltogether, or not doing so using that expression (same applies to XMLHTTP).

Hope this helps

thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML in JavaScript for Mozilla jwalborn Javascript 2 February 6th, 2008 11:47 AM
Transform XML with XSLT in JavaScript Mozilla Spankmaster79 Javascript 3 January 18th, 2006 07:31 AM
XML Javascript + Netscape equivalent sasidhar79 XML 0 October 19th, 2004 02:49 AM
XML & Netscape Greg Griffiths Javascript How-To 13 September 30th, 2004 10:20 AM
XML and netscape / Mozilla madhukp Classic ASP XML 0 May 3rd, 2004 04:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.