这个标题想了好一会,不知道这样的表示是否能让除我以外的读者看得明白。这个问题折腾了我几个小时,后来发现这个问题的解决方法又是那么的简单。这里记录下来帮助后面的人少走弯路,也给自己提个醒。
需要解析的XML 如下:
view plaincopy to clipboardprint?
01.<Project name="ibibogame" type="0x0301" mode="public" exporter="GameForIN" version="1.0.0.1">
02. <Task name="downloadandopenroom">.\downloadandopenroom\downloadandopenroom\downloadandopenroom.ztask</Task>
03. <Task name="spectator">.\spectator\spectator\spectator.ztask</Task>
04. <Task name="quickmatch">.\quickmatch\quickmatch\quickmatch.ztask</Task>
05. <Task name="buddystate" state="active">.\buddystate\buddystate\buddystate.ztask</Task>
06. <Task name="buddyfunction">.\buddyfunction\buddyfunction\buddyfunction.ztask</Task>
07. <Task name="chatinroom">.\chatinroom\chatinroom.ztask</Task>
08. <Task name="privatechat">.\privatechat\privatechat\privatechat.ztask</Task>
09. <Task name="inviteothers">.\inviteothers\inviteothers\inviteothers.ztask</Task>
10.</Project>
<Project name="ibibogame" type="0x0301" mode="public" exporter="GameForIN" version="1.0.0.1">
<Task name="downloadandopenroom">.\downloadandopenroom\downloadandopenroom\downloadandopenroom.ztask</Task>
<Task name="spectator">.\spectator\spectator\spectator.ztask</Task>
<Task name="quickmatch">.\quickmatch\quickmatch\quickmatch.ztask</Task>
<Task name="buddystate" state="active">.\buddystate\buddystate\buddystate.ztask</Task>
<Task name="buddyfunction">.\buddyfunction\buddyfunction\buddyfunction.ztask</Task>
<Task name="chatinroom">.\chatinroom\chatinroom.ztask</Task>
<Task name="privatechat">.\privatechat\privatechat\privatechat.ztask</Task>
<Task name="inviteothers">.\inviteothers\inviteothers\inviteothers.ztask</Task>
</Project>
这里设置 XMLReader 如下:
view plaincopy to clipboardprint?
01.reader: new Ext.data.XmlReader(
02. {record: 'Task'}, //设置这里的循环节点为 Task
03. [
04. {name: 'Task Name', mapping: '@name'}, //读取节点内的属性值
05. {name: 'Task', mapping:''} //直接用''读取节点下的内容
06. ])
reader: new Ext.data.XmlReader(
{record: 'Task'}, //设置这里的循环节点为 Task
[
{name: 'Task Name', mapping: '@name'}, //读取节点内的属性值
{name: 'Task', mapping:''} //直接用''读取节点下的内容
])
....................................................................