0

我正在使用 EXTjs 并尝试通过 ajax 连接到服务器并以 xml 格式获取输出。有 3 个文本框需要填充这些 xml 值

response.responseText 给了我结果,但是 response.responseXML 给了 null。有什么方法可以将 responseText 转换为 responseXML,然后将值分配给文本框。有人能帮帮我吗?

function getXML(){
    Ext.Ajax.request({
            url : 'url',
            params  : {
                   method   : 'runxml'
                },
            method  : 'POST',
            success : function(response, options) {
                alert(response.responseXML);
                alert(response.responseText);       

            },
            failure : function(response, options) {
                Ext.MessageBox.show({
                    title   : 'Error On retrieve value from server',
                    msg : 'An error occur during retrieve value from server',
                    buttons : Ext.MessageBox.OK,
                    icon    : Ext.MessageBox.ERROR,
                    width   : 400
                    });
                },
                disableCaching  : true
            });
            }

}

我从 response.responseText 得到的输出是

<wddxPacket version='1.0'><header/>
<data><string>&lt;?xml version="1.0" encoding="iso-8859-1" ?&gt;
<char code='0a'/>&lt;TABLE&gt;
<char code='0a'/>&lt;LIMITS&gt;
<char code='0a'/>&lt;UCL&gt; 5.23145 &lt;/UCL&gt;
<char code='0a'/>&lt;CTL&gt; 3.0269 &lt;/CTL&gt;
<char code='0a'/>&lt;LCL&gt; 1.458&lt;/LCL&gt;
<char code='0a'/>&lt;/LIMITS&gt;
<char code='0a'/>&lt;/TABLE&gt;
<char code='0a'/></string></data></wddxPacket>
4

1 回答 1

0

Have you set the Content-Type header in the HTTP response as "text/xml" or "application/xml". Because for browser to parse a returned XML document, the Content-Type header in the HTTP response must be set to "text/xml" or "application/xml". This is very important - the XmlReader will not work correctly otherwise.

于 2012-11-22T08:07:07.490 回答