I am trying to get some xml datas from webservice. I can access all data but i cannot get one by one. I want write data to div that has id "code". It writes [object Element]. What i have to do?
<script type="text/javascript">
$(document).ready(function () {
var returnValue = localStorage.getItem("returnValue");
var userName = localStorage.getItem("userName");
alert("Hello" + userName);
var wsUrl = "http://xxx=GetStocks";
var soapRequest =
'<?xml version="1.0" encoding="utf-8"?>\
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\ xmlns:xsd="http://www.w3.org/2001/XMLSchema"\ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\
<soap:Body>\
<GetStocks xmlns="http://sales.xxx.org/">\
<token>' + returnValue + '</token>\
</GetStocks>\
</soap:Body>\
</soap:Envelope>';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: processSuccess,
error: processError
});
});
function processSuccess(data, status, req) {
if (status == "success") {
var stocks = $(req.responseXML).find("pStockInfo");
var codes = $(req.responseXML).find("Code");
var stocksCount = stocks.length;
$("#code").text(codes[0]); //Here i want first code.
}
}
function processError(data, status, req) {
alert(req.responseText + " " + status);
}
</script>
Xml Data
I want get first code "FO19428"