开发者

get the record value from XML Store in EXT js

I am ExtJS for GUI development. I am using XML Store for retrieving the 开发者_运维问答data from server.

My XML looks like this.

<meta>
 <entry>x</entry>
 <entry>Y</entry>
</meta>
<data>
  <value>100</value>
  <value>500</value>
 </data>

Where X=100 and Y=500

How do i retrieve the data and value from this using XMLStore?


Since the XML structure is not really suitable for what the XML Store/Reader expect, I suggest you parse the XML yourself into a more standard format and then load the data to a JsonStore for example.

Parsing code: (wrote it off the top of my head, so might need some adjustments ...)

var data = [];
var q = Ext.DomQuery;
var entries = q.select('meta > entry', theXML);
var values = q.select('data > value', theXML);
for (var i = 0; i < entries.length; ++i) {
    var recordData = {
        entry: entries[i].firstChild.nodeValue,
        value: values[i].firstChild.nodeValue
    }
    data.push(recordData);
}

Hope it will be useful to you ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜