XML在Firefox中格式不正确,无法从服务器获取xml响应 [英] XML Not well formed in Firefox getting xml response from server

查看:64
本文介绍了XML在Firefox中格式不正确,无法从服务器获取xml响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用的是jQGrid最新版本.以下是我配置的完整配置.

I am using jQGrid Latest version in my project.following is complete configuration that i configured.

jQuery("#list").jqGrid( {
        url : 'Link.do?method=findAllBrand',
        mtype : 'GET',
        height : 350,
        datatype : "xml",
        colNames : [ 'Name' ],
        colModel : [ {
            name : 'name',
            index : 'name',
            width : 620
        } ],
        rowNum : 10,
        rowList : [ 10, 20, 30 ],
        sortname : 'id',
        sortorder : "desc",
        viewrecords : true,
        multiselect : true,
        imgpath : 'themes/base/images',
        caption : "Brand (s) Summary Grid",
        pager : $('#pager'),
        cache : false,
        onSelectRow : function(id) {

        }
    });

我正在从服务器获取xml形式的以下数据:

I am getting following data in form of xml from server :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><rows><page>1</page><total>1</total><records>4</records><row id="BRD00003"><cell>Blanco</cell></row><row id="BRD00001"><cell>Bosch</cell></row><row id="BRD00004"><cell>Chef</cell></row><row id="BRD00002"><cell>F&P</cell></row></rows>

我知道在最后一行的最后一个单元中正在创建问题,因为它包含& char在xml中具有特殊含义.但是我使用下面的函数使用Apache commons lang库对整个xml进行了转义.

i know that in the last cell of last row is creating problem , because it contains & char which has special meaning in the xml. however i have escaped sequence the whole xml using Apache commons lang library using below function.

toXml = StringEscapeUtils.escapeXml(toXml);

,结果字符串为

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;&lt;rows&gt;&lt;page&gt;1&lt;/page&gt;&lt;total&gt;1&lt;/total&gt;&lt;records&gt;4&lt;/records&gt;&lt;row id=&quot;BRD00003&quot;&gt;&lt;cell&gt;Blanco&lt;/cell&gt;&lt;/row&gt;&lt;row id=&quot;BRD00001&quot;&gt;&lt;cell&gt;Bosch&lt;/cell&gt;&lt;/row&gt;&lt;row id=&quot;BRD00004&quot;&gt;&lt;cell&gt;Chef&lt;/cell&gt;&lt;/row&gt;&lt;row id=&quot;BRD00002&quot;&gt;&lt;cell&gt;F&amp;P&lt;/cell&gt;&lt;/row&gt;&lt;/rows&gt;

在Mozilla firefox最新版本和chrome中,我仍然遇到相同的错误,即7,8.

still i got the same error in Mozilla firefox latest version and in chrome , ie 7,8 also.

我必须向您展示这个特殊字符,以便如何解决此问题?

谢谢 米希尔·帕雷克(Mihir Parekh)

Thank You Mihir Parekh

推荐答案

我正在从服务器端生成xml.

i am generating the xml from server side.

然后分别转义每个文本节点和每个属性值,就这么简单.

Then escape each text node and each attribute value separately, it's all simple as that.

这篇关于XML在Firefox中格式不正确,无法从服务器获取xml响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆