Jquery ajax得到xml解析错误

时间:2017-07-04 23:26:03

标签: javascript jquery ajax xml

我想从Jquery ajax https://sisa.msal.gov.ar/sisa/services/rest/puco/44003375

中获取此URL中的XML

通过浏览器我可以看到:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<puco>
 <resultado>OK</resultado>
 <coberturaSocial>O.S.P. CIUDAD AUT</coberturaSocial>
<denominacion>AGOSTINO RODRIGO LEONARDO</denominacion>
<nrodoc>44003375</nrodoc>
<rnos>901001</rnos>
<tipodoc>DNI</tipodoc>
</puco>

但在做的时候:

var id=44003375;
$.ajax({
    type : "GET",
    url  : 'https://sisa.msal.gov.ar/sisa/services/rest/puco/'+id,
    dataType :"JSONP",
    jsonp: true,
    success : function(xhr){
      alert(JSON.stringify(xhr));
    },
    error : function(httpReq,status,exception){
      var clientid = $(httpReq).text();
      alert(JSON.stringify(httpReq));
    }
 });

返回“解析错误”...我如何通过ajax获取浏览器显示的内容?

3 个答案:

答案 0 :(得分:0)

使用JavaScript .load(),然后将XML解析为JSON as detailed here

答案 1 :(得分:0)

您将需要使用任何xml到json转换器或解析器。看看http://goessner.net/download/prj/jsonxml/

答案 2 :(得分:0)

我解决了,但是用PHP

    try {
        seconds = gui.getSeconds() * 1000;
    } catch (Exception e) {

    }

    while (!Thread.currentThread().isInterrupted()) {

        robot.delay(seconds);

        for (int i = 0; i < temp.length(); i++) {
            typeThis(test[i]);
        }

        if (enter) {
            typeNow(VK_ENTER);
        }
    }