javascript XMLSerializer find string not working in ie

hooperbobber

New Member
This piece of code is working fine in Mozilla and Chrome, but not in IE. I want to parse the XML string. The input to the function "ParseingXML" is name tag like 'Siddhu' or 'dfDads'. It should return a mobile number of particular contact.In IE, it is returning "False" at the line -- > $(content).find('CONTACT').each (function()Sample XML :\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><CONTACTS> <CONTACT> <name>Siddhu</name> <email>[email protected]</email> <phone>9646546000</phone> <dob>06/13/2012</dob> </CONTACT> <CONTACT> <CONTACT> <name>dfDads</name> <email>[email protected]</email> <phone>95644550797</phone> <dob>07/13/1985</dob> </CONTACT></CONTACTS>\[/code\]Source:\[code\] function parsingXml(text) { if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else // for IE 5/6 { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET", "contacts.xml", false); xhttp.send(); var xmlDoc = xhttp.responseXML; var content = xhttp.responseText //var serializer = new XMLSerializer (); //content = serializer.serializeToString (xmlDoc); try { content = (new XMLSerializer()).serializeToString(xmlDoc); } catch (e) { // FOr IE content = xmlDoc.xml; //content = "<div>" + content + "</div>"; alert(content); } $(content).find('CONTACT').each(function () { if ($(this).find('name').text() == text) { // alert($(this).find('phone').text()); var numb = $(this).find('phone').text(); //alert(numb); //return numb; var textbox = document.getElementById('droppable'); textbox.value = http://stackoverflow.com/questions/11101646/numb; //$("#droppable").value = http://stackoverflow.com/questions/11101646/numb; } }); //alert('hi'); };});\[/code\]
 
Back
Top