我在做一个系统,需要访问远程一个xml文件,我想把数据拿过来用xml展示,貌似extjs只有json格式才可以支持。请问我要怎么转换?
晕呢,extjs连xml都不支持了,extjs对xml是完美支持的.你可以参考下面的例子.多看官网示例呀.哥们
[url]http://extjs.com/deploy/dev/examples/grid/xml-grid.html[/url]
你查一下api吧...XmlReader
Example code:
[code="java"]var Employee = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.XmlReader({
totalRecords: "results", // The element which contains the total dataset size (optional)
record: "row", // The repeated element which contains row information
id: "id" // The element within the row that provides an ID for the record (optional)
}, Employee);[/code]
This would consume an XML file like this:
[code="java"]<?xml version="1.0" encoding="UTF-8"?>
2
1
Bill
Gardener
2
Ben
Horticulturalist
[/code]