论坛首页 Web前端技术论坛

extjs 解析xml

浏览 3123 次
锁定老帖子 主题:extjs 解析xml
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-04-18  
EXT
<dataobject version="1.0" processing="1" rowcheckbox="no"
rowsperpage="20" description="物料种类" columnmove="yes" readonly="yes">
<gridlines color="#C0C0C0"
position="68,215,400,593,670,810,860,954,1064,1178,1580" />
<datasource type="sqlselect">
<sqlselect>select * from SLC_TM_WLZL</sqlselect>
<filter />
<sort>id D</sort>
<sqlselectretrieved>select
`ID`,`cInvCode`,`cInvName`,`cFree4`,`shl`,`cInvStd`,`cFree1`,`cFree2`,`cFree3`,`cinvstd_1`,`cMemo`
FROM SLC_TM_WLZL</sqlselectretrieved>
<table pname="SLC_TM_WLZL" gname="SLC_TM_WLZL" quote="no" alias=""
schema="" catalog="" type="TABLE" update="yes" updateclause="2">slc_tm_wlzl
</table>

<col tableid="1" pname="cinvstd_1" fname="`cinvstd_1`" quote="yes"
alias="" type="VARCHAR" classint="1" nullable="yes" pk="no"
precision="200" scale="0" label="产品规格型号" isquery="no" coltype="string"
key="no" update="yes" fillback="none">cinvstd_1</col>
<col tableid="1" pname="cMemo" fname="`cMemo`" quote="yes" alias=""
type="VARCHAR" classint="1" nullable="yes" pk="no" precision="1073741823"
scale="0" label="备注" isquery="no" coltype="string" key="no" update="yes"
fillback="none">cmemo</col>
</datasource>
<titlebar height="0" backgroundcolor="white" heightautosize="no" />
<header height="20" backgroundcolor="white" heightautosize="no" />
<detail height="20" backgroundcolor="white" heightautosize="yes" />
<summary height="0" backgroundcolor="white" heightautosize="yes" />
<footer height="0" backgroundcolor="white" heightautosize="no" />
<text name="text_1" band="Header" align="center" x="0" y="0"
width="67" height="20" text="ID" fontweight="bold" backgroundcolor="#c0c0ff" />
<text name="text_2" band="Header" align="center" x="68" y="0"
width="146" height="20" text="材料编码" fontweight="bold" backgroundcolor="#c0c0ff" />
<text name="text_3" band="Header" align="center" x="215" y="0"
width="184" height="20" text="材料名称" fontweight="bold" backgroundcolor="#c0c0ff" />
</dataobject >
这种不规则、没层次的文件怎么用extjs解析
   发表时间:2013-04-18  
<?xml version="1.0" encoding="UTF-8"?>
<deeply>
    <nested>
        <xml>
            <users>
                <user>
                    <id>3</id>
                    <name>Ed Spencer</name>
                    <email>ed@sencha.com</email>
                </user>
                <user>
                    <id>4</id>
                    <name>Abe Elias</name>
                    <email>abe@sencha.com</email>
                </user>
            </users>
        </xml>
    </nested>
</deeply>比较容易
0 请登录后投票
   发表时间:2013-04-18  
{
    "users": [
        {
            "id": 123,
            "name": "Ed",
            "orders": [
                {
                    "id": 50,
                    "total": 100,
                    "order_items": [
                        {
                            "id"      : 20,
                            "price"   : 40,
                            "quantity": 2,
                            "product" : {
                                "id": 1000,
                                "name": "MacBook Pro"
                            }
                        },
                        {
                            "id"      : 21,
                            "price"   : 20,
                            "quantity": 3,
                            "product" : {
                                "id": 1001,
                                "name": "iPhone"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
也可以,但是我最上面的弄不出来了,大拿们给个示例
0 请登录后投票
   发表时间:2013-05-07  
Ext里面没有专门解析xml的功能,只有store有一个xmlreader,也可以正常解析。

不知道你要什么样的功能?

如果要普通的从xml字符串解析到xml对象,要自己写一个兼容代码。

这个怎么贴代码?我这里有一个可以从xml字符串解析到xml对象的代码,不知道怎么贴上来。xml对象支持selectNodes, selectSingleNode等等常用方法。
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics