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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parsing external or remote XML file through javascript

    When I try to parse xml fixed string following code works fine. When I try to parse the string get from remote server.(bellow code example) It gives me an error unterminated string. I think this error is because of large string.How can I parse external xml file i.e http://abc.xml from the javascript ???

    Code:
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
    
    function loadXML(strXML) 
    { 
    
     xmlDoc.async="false"; 
     xmlDoc.onreadystatechange=verify; 
     xmlDoc.loadXML(strXML); 
    
     xmlObj=xmlDoc.documentElement; 
    }
    
    function verify() 
    { 
     // 0 Object is not initialized 
     // 1 Loading object is loading data 
     // 2 Loaded object has loaded data 
     // 3 Data from object can be worked with 
     // 4 Object completely initialized 
     if (xmlDoc.readyState != 4) 
     { 
       return false; 
     } 
    }
    
    function loadData(){//start function
    
    var strXML=strReturnXML="";
    
    strReturnXML="<response><request type='destination list' id='8'><language_code>ING</language_code>"+
    "<agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request><country><code>ES</code><description>SPAIN</description><destination><code>IBZ</code><description>IBIZA</description><zone><code>20</code><description>SAN ANTONIO [CENTRO]</description></zone></destination><destination><code>PMI</code><description>MALLORCA</description><zone><code>20</code><description>PLAYA DE PALMA</description></zone><zone><code>31</code><description>SANTA PONSA</description></zone></destination><destination><code>MAH</code><description>MENORCA</description><zone><code>10</code><description>MAHON</description></zone></destination></country><country><code>PT</code><description>PORTUGAL</description><destination><code>FAO</code><description>ALGARVE</description><zone><code>80</code><description>ALBUFEIRA</description></zone></destination></country></response>";
    
    loadXML(strReturnXML);
    -----------------------------------------------------------------------------------------------------------

    Code:
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
    
    function loadXML(strXML) 
    { 
    
     xmlDoc.async="false"; 
     xmlDoc.onreadystatechange=verify; 
     xmlDoc.loadXML(strXML); 
    
     xmlObj=xmlDoc.documentElement; 
    }
    
    function verify() 
    { 
     // 0 Object is not initialized 
     // 1 Loading object is loading data 
     // 2 Loaded object has loaded data 
     // 3 Data from object can be worked with 
     // 4 Object completely initialized 
     if (xmlDoc.readyState != 4) 
     { 
       return false; 
     } 
    }
    
    function loadData(){//start function
    
    
    
    	strXML="<barceloDS_requests><request type='destination list' id='8'><language_code>ING</language_code><agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request></barceloDS_requests>";
    	
    		var strUrl="http://195.57.250.36/barceloDS/interface/xml";
    		
    		var objXMLHttp= new ActiveXObject("Microsoft.XMLHTTP");
    		//var objXMLHttp = new XMLHttpRequest();
    
    
    			objXMLHttp.open("POST", strUrl, true);
    			objXMLHttp.setRequestHeader("Content-type", "text/plain");
                objXMLHttp.send(strXML);
    			//var strServerProcess=objXMLHttp.responseXML.strXML;
    			//document.write(objXMLHttp.responseText);
    			//alert(objXMLHttp);
    			 objXMLHttp.onreadystatechange = function() { 
    			   if (objXMLHttp.readyState == 4 && objXMLHttp.status == 200) { 
    				  strReturnXML=objXMLHttp.responseText; 
    				//  document.write(objXMLHttp.responseText);
    			   } 
    		 	  }
    			//objXMLHttp.send(null); 
    
    	
    loadXML(strReturnXML);
    
    }

  • #2

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I recieved your P/M and in response....

    No, they have all not been unaswered... Many of the threads you started were responded too and many people asked you for clarification (one example I am personally aware of is Josh responding to one of the three post you made on Weborum Forums)...

    I also responded and provided a working example of an XML HTTPrequest script I use to one of your numerous posts on Weburom but I had it removed when I discovered that you keep starting new threads without following up on the ones that you previously started...

    And no, I'm not wasting my time providing the code again... I only hope you learn that peoples time is valuable and you should respect their effort in replying to your questions by at least acknowledging their response and answer any questions they may have....

    Have many nice days;
    .....Willy


    Quote Originally Posted by munnan
    Hello Willy,
    I have recd your reply against my thread "Parsing external or remote XML file through javascript"
    :
    http://www.sitepoint.com/forums/showthread.php?t=217435
    http://www.webtribunal.com/showthread.php?threadid=646
    http://www.sitepoint.com/forums/showthread.php?t=214335
    http://www.sitepoint.com/forums/showthread.php?t=215312
    http://coderforums.com/archive/topic/3811-1.html
    http://forum.weborum.com/index.php?showtopic=2208
    http://forum.weborum.com/index.php?showtopic=2087
    http://forum.weborum.com/index.php?showtopic=2127

    And there is another 25 or so other threads started without the O/P ever returning and replying to anyone trying to help and asking for further clarification or offering advice...

    .....Willy


    I want to clarify a thing here,that all the threads that you have indicated above are all mine submitions,but you can see from the threads that nobody has replied to mine threads,so I have to use other forums (all available resources) to submit and get some kind of clue from there,that is the reason behind all the threads,
    anyways if you can give me a clue for the solution of my problem(http://www.codingforums.com/showthre...278#post257278),that will be nice of you,
    By
    Munnan


  •  

    Posting Permissions

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