<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<exampleResponse xmlns:ns1="http://hellows">
<ns1:out>消息是:sdf</ns1:out>
</exampleResponse>
</soap:Body>
</soap:Envelope>怎样取出?
消息是:sdf
<soap:Body>
<exampleResponse xmlns:ns1="http://hellows">
<ns1:out>消息是:sdf</ns1:out>
</exampleResponse>
</soap:Body>
</soap:Envelope>怎样取出?
消息是:sdf
$(xmlResult).find("exampleResponse").children().eq(0).text());
因为find('ns1:out'),jquery会认为是找有out属性的ns1.
最后多了个括号刚才
cokeetang,我试过你给我的方法但还不行!
var resultNode = xmlResult.documentElement.firstChild.firstChild.firstChild;
var resultValue = resultNode.firstChild.nodeValue;
alert(resultValue);
这样可以实现,jq如何?
document.createElement("exampleResponse");一下才行。
下面可运行的IE代码,你试下,根据你的情况改:
<html>
<head>
<script type="text/javascript" src='jquery.js'></script>
<script type="text/javascript">
document.createElement("exampleResponse");
$(function(){
alert($("body").find("exampleResponse").text());
});
</script>
</head>
<body>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<exampleResponse xmlns:ns1="http://hellows">
<ns1:out>消息是:sdf </ns1:out>
</exampleResponse>
</soap:Body>
</soap:Envelope>
</body>
</html>