title: How to Parse XML Response Using jQuery
body: <p>I am trying to parse an xml response using jQuery and just output an element the a page but i am unsuccessful in this.</p>
  
  <p>Below is the code that I am using for the response &amp; parsing of it.</p>
  
  <pre><code>$.ajax({
      url: UCMDBServiceUrl,
      type: "POST",
      dataType: "xml",
      data: soapMessage,
      success: UCMDBData,
      crossDomain: true,
      contentType: "text/xml; charset=\"utf-8\""
  });
  alert("Sent2");
  return false;
  }
  
  function UCMDBData(xmlHttpRequest, status, msg)
  {
       alert("Came back1");
       $(xmlHttpRequest.responseXML).find('tns:CIs').each(function()
       {
          alert("Came back2");
          $(this).find("ns0:CI").each(function()
          {
              alert("Came back3");
              $("#output").append($(this).find("ns0:ID").text());
          });
       });     
  }
  </code></pre>
  
  <p>I am receiving alerts for "Came back1" but it doesnt appear to be going any further. Below is the XML Response that I am trying to parse using my above jquery code. The text that I am ultimately trying to return out of the response is in this element </p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Header /&gt;
      &lt;soapenv:Body&gt;
          &lt;tns:getFilteredCIsByTypeResponse xmlns:ns0="http://schemas.hp.com/ucmdb/1/types" xmlns:ns1="http://schemas.hp.com/ucmdb/ui/1/types" xmlns:ns2="http://schemas.hp.com/ucmdb/1/types/query" xmlns:ns3="http://schemas.hp.com/ucmdb/1/types/props" xmlns:ns4="http://schemas.hp.com/ucmdb/1/types/classmodel" xmlns:ns5="http://schemas.hp.com/ucmdb/1/types/impact" xmlns:ns6="http://schemas.hp.com/ucmdb/1/types/update" xmlns:ns7="http://schemas.hp.com/ucmdb/discovery/1/types" xmlns:ns8="http://schemas.hp.com/ucmdb/1/types/history" xmlns:tns="http://schemas.hp.com/ucmdb/1/params/query"&gt;
              &lt;tns:CIs&gt;
                  &lt;ns0:CI&gt;
                      &lt;ns0:ID&gt;4d030502995a00afd989d3aeca2c990c&lt;/ns0:ID&gt;
                      &lt;ns0:type&gt;nt&lt;/ns0:type&gt;
                      &lt;ns0:props&gt;
                          &lt;ns0:strProps&gt;
                              &lt;ns0:strProp&gt;
                                  &lt;ns0:name&gt;name&lt;/ns0:name&gt;
                                  &lt;ns0:value&gt;prodoo&lt;/ns0:value&gt;
                              &lt;/ns0:strProp&gt;
                          &lt;/ns0:strProps&gt;
                          &lt;ns0:booleanProps&gt;
                              &lt;ns0:booleanProp&gt;
                                  &lt;ns0:name&gt;host_iscomplete&lt;/ns0:name&gt;
                                  &lt;ns0:value&gt;false&lt;/ns0:value&gt;
                              &lt;/ns0:booleanProp&gt;
                          &lt;/ns0:booleanProps&gt;
                      &lt;/ns0:props&gt;
                  &lt;/ns0:CI&gt;
              &lt;/tns:CIs&gt;
              &lt;tns:chunkInfo&gt;
                  &lt;ns0:numberOfChunks&gt;0&lt;/ns0:numberOfChunks&gt;
                  &lt;ns0:chunksKey&gt;
                      &lt;ns0:key1 /&gt;
                      &lt;ns0:key2 /&gt;
                  &lt;/ns0:chunksKey&gt;
              &lt;/tns:chunkInfo&gt;
          &lt;/tns:getFilteredCIsByTypeResponse&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>So my question is that how do I properly parse the data? I believe the code syntax is correct but I am not getting the expected returned results. I would appreciate any help, thanks.</p>
  
  <p>EDIT</p>
  
  <p>I have modified my code to the following like the suggestion, but still no luck:</p>
  
  <pre><code>$.ajax({
      url: UCMDBServiceUrl,
      type: "POST",
      dataType: "xml",
      data: soapMessage,
      success: UCMDBData,
      crossDomain: true,
      contentType: "text/xml;"
      });
  alert("Sent2");
  return false;
  }
  
  function UCMDBData(data, textStatus, jqXHR) {
      alert("Came back1");
      $(data).find('tns:CIs').each(function () {
          alert("Came back2");
          $(this).find("ns0:CI").each(function () {
              alert("Came back3");
              $("#output").append($(this).find("ns0:ID").text());
              document.AppServerForm.outputtext.value = document.AppServerForm.outputtext.value + "http://localhost:8080/ucmdb/cms/directAppletLogin.do?objectId=" + $(this).find('ns0:ID').text() +"&amp;infopane=VISIBLE&amp;navigation=true&amp;cmd=ShowRelatedCIs&amp;interfaceVersion=8.0.0&amp;ApplicationMode=ITU&amp;customerID=1&amp;userName=admin&amp;userPassword=admin";
  
      });
  });
  </code></pre>
  
  <p>}</p>
  
  <p>When I execute the only alert message i receive back is "Came back1" which means that the code is still not going through the xml properly with jquery. Any other suggestions?</p>