×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    29

    XML Parsing Issue and How to solve this issue?

    Hi,

    I have created the sample code for xml parsing , it working fine in wrt , but not working in wen app.
    here a i am shows the sample code and xml structure.
    I used Soap web service.
    XML file Link :http://dl.dropbox.com/u/57983664/Folder/Untitled-2.xml

    Code:
    function init()
    {
    var symbol = "MSFT"; 
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", "http://dl.dropbox.com/u/57983664/Folder/Untitled-2.xml",true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState == 4) {
     	var xmlDoc = xmlhttp.responseText;
     	headers =xmlhttp.getAllResponseHeaders().toLowerCase();
    				if (window.DOMParser) {
    				var parser = new DOMParser();
    				var xmlPar = parser.parseFromString(xmlDoc, "text/xml");
    			}
    			var ResponseCode = xmlPar.getElementsByTagName("RCode");
    			if (ResponseCode[0].childNodes[0].nodeValue == '200-success') {
    			 
    			 Name=xmlPar.getElementsByTagName("AN");
    			 
    			 var contents="<table border=1 cellpadding='4' cellspacing='2'>";
    			 var trcontents="";
    			 alert(Name.length);
    			 for(var i=0;i<Name.length;i++)
    			 {
    			 	nameValue=Name[i].childNodes[0].nodeValue;
    				alert("n"+nameValue);
    				trcontents=trcontents+"<tr><td>"+nameValue+"</td></tr>";
    			 }
    			 aboutdetails=contents+trcontents+"</table>";
    			 document.getElementById('about').innerHTML =aboutdetails;
    			//mwl.insertHTML("#about", aboutdetails);
    			
    			}
    	
      }
    }
    xmlhttp.setRequestHeader("SOAPAction", "http://cell.in");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    var xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sear="cell.in">'+
       '<soapenv:Header/>'+
       '<soapenv:Body>'+
          '<sear:MMT_FlightSearchRQ>'+
            '<sear:TripType>R</sear:TripType>'+
             '<sear:OriginLocation>DEL</sear:OriginLocation>'+
             '<sear:DestinationLocation>BOM</sear:DestinationLocation>'+
             '<sear:DepartureDateTime>2012-01-20T00:01:00</sear:DepartureDateTime>'+
             '<sear:ReturnDateTime>2012-01-21T00:01:00</sear:ReturnDateTime><sear:Class>E</sear:Class>'+
             '<sear:NoofAdults>1</sear:NoofAdults>'+
             '<sear:NoofStops>1</sear:NoofStops><sear:ResidentOfIndia>true</sear:ResidentOfIndia>'+
             '<sear:LCCStatus>false</sear:LCCStatus>'+
             '<sear:NightFlight>false</sear:NightFlight>'+
           '</sear:MMT_FlightSearchRQ>'+
       '</soapenv:Body>'+
    '</soapenv:Envelope>';
    xmlhttp.send(xml);
    
    }
    what should i do?
    Last edited by isalento; 2012-01-20 at 11:36. Reason: CODE tags

  2. #2
    Nokia Developer Moderator
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: XML Parsing Issue and How to solve this issue?

    Hi,

    I tried to take a look, but the code is obviously missing something.

    Could you please post the code snippet again using &#x5b;CODE&#x5d; &#x5b;/CODE&#x5d; tags?
    Discussion board is not showing the special markup without using those tags.

    Thanks

    -Ilkka

  3. #3
    Nokia Developer Moderator
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: XML Parsing Issue and How to solve this issue?

    Hi,

    I took liberty to add missing code tags.

    The issue seems to be with how namespaces are handled by getElementsByTagName.
    It fails to find tags with just "RCode".

    Fixing this will require following changes to be made.

    Code:
    var ResponseCode = xmlPar.getElementsByTagNameNS("*","RCode");
    var name = xmlPar.getElementsByTagNameNS("*","AN");
    Br,
    Ilkka

  4. #4
    Registered User
    Join Date
    Aug 2011
    Posts
    29

    Re: XML Parsing Issue and How to solve this issue?

    Hi please see this code .I got xml response from server But could not parse it. I pasted this code in between this tag .

    Code:
    var xmlhttp="";
    var Name="";
    var nameValue="";
    var aboutdetails="";
    function init()
    {
    var symbol = "MSFT"; 
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", "http://dl.dropbox.com/u/57983664/Folder/Untitled-2.xml",true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState == 4) {
     	var xmlDoc = xmlhttp.responseText;
     	headers =xmlhttp.getAllResponseHeaders().toLowerCase();
    				if (window.DOMParser) {
    				var parser = new DOMParser();
    				var xmlPar = parser.parseFromString(xmlDoc, "text/xml");
    			}
    			else // Internet Explorer
    			{
    				var xmlPar = new ActiveXObject("Microsoft.XMLDOM");
    				xmlPar.async = "false";
    				xmlPar.loadXML(xmlDoc);
    			}
    			
    			var ResponseCode = xmlPar.getElementsByTagName("RCode");
    			if (ResponseCode[0].childNodes[0].nodeValue == '200-success') {
    			 
    			 Name=xmlPar.getElementsByTagName("AN");
    			 
    			 var contents="<table border=1 cellpadding='4' cellspacing='2'>";
    			 var trcontents="";
    			 for(var i=0;i<Name.length;i++)
    			 {
    			 	nameValue=Name[i].childNodes[0].nodeValue;
    				trcontents=trcontents+"<tr><td>"+nameValue+"</td></tr>";
    			 }
    			 aboutdetails=contents+trcontents+"</table>";
    			 document.getElementById('about').innerHTML =aboutdetails;
    			//mwl.insertHTML("#about", aboutdetails);
    			
    			}
    	
      }
    }
    xmlhttp.setRequestHeader("SOAPAction", "http://cell.in");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.send(xml);
    
    }
    Regards,
    Geenbil

  5. #5
    Nokia Developer Moderator
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: XML Parsing Issue and How to solve this issue?

    Thanks Greenbil!
    Did you already try to parse using following syntax?
    Code:
    //var ResponseCode = xmlPar.getElementsByTagName("RCode");
    var ResponseCode = xmlPar.getElementsByTagNameNS("*","RCode")
    -Ilkka

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    29

    Re: XML Parsing Issue and How to solve this issue?

    Hi,

    It works fine thanks.

    Regards,
    Greenbil.

Similar Threads

  1. XML Parsing Issue
    By nisheethpandey in forum Symbian
    Replies: 6
    Last Post: 2009-11-05, 13:41
  2. Please help me to solve this issue.
    By ramesh12 in forum Symbian
    Replies: 1
    Last Post: 2009-08-24, 14:42
  3. How to solve DLL build issue?
    By micojade in forum Symbian
    Replies: 1
    Last Post: 2008-10-30, 22:49
  4. how to solve this issue?...........
    By bharats in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-02-17, 09:45
  5. Did you solve this issue?
    By waperman in forum General Development Questions
    Replies: 0
    Last Post: 2004-03-02, 18:39

Posting Permissions

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