怎么解析request请求返回来的数据
返回的是这样的,比如我只需要error msg里面的"Not in GZIP format" ,要怎么解析
<?xml version=“1.0” encoding=“GBK”?><soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/” soap:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”><soap:Header><out:system xmlns:out=“http://www.ylzinfo.com/”></out:system></soap:Header><soap:Body><soap:Fault><faultcode>600</faultcode><faultstring><error msg=“Not in GZIP format” /></faultstring></soap:Fault></soap:Body></soap:Envelope>
6 回复
var str = '<?xml version="1.0" encoding="GBK"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><soap:Header><out:system xmlns:out="http://www.ylzinfo.com/"></out:system></soap:Header><soap:Body><soap:Fault><faultcode>600</faultcode><faultstring><error msg="Not in GZIP format" /></faultstring></soap:Fault></soap:Body></soap:Envelope>' ; var m = str.match(/<faultcode>(\d+)<\/faultcode>/); console.log(m[1]); |