Hi guys,
I'm building a simple extjs reader that connects to a j2EE web service and displays the results. My problem is I don't know how I can map the XmlReader where there are multiple child node instances. Example xml:
Code:
- <result>
- <attributes>
<attribute>Geometry type: 4</attribute>
<attribute>Exterior ring: 1</attribute>
<attribute>Point count: 5</attribute>
<attribute>Lambert_Conformal_Conic</attribute>
<attribute>85758</attribute>
<attribute>993f75ed-dfc0-4d84-8d95-29462313f331</attribute>
<attribute>morrisonb</attribute>
<attribute>Thu May 27 00:00:00 CST 2010</attribute>
<attribute>4</attribute>
</attributes>
- <extent>
<minx>-480848.0771999992430210113525390625</minx>
<maxx>-479586.4708000011742115020751953125</maxx>
<miny>231779.4936999976634979248046875</miny>
<maxy>233042.39090000092983245849609375</maxy>
</extent>
</result>
And the javascript
Code:
Ext.onReady(function() {
//Create the data store.
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method: 'GET',
disableCaching:true,
url:"http://localhost:8085/agmafWSCplSearch/rest/attributeSearch?attr=township&attrv=16&attr=range&attrv=14&attr=meridian&attrv=w1&attr=section&attrv=10"
}),
reader: new Ext.data.XmlReader({
record: 'result'
},[
{name: 'SR', mapping: 'attributes > attribute[1]'},
{name: 'MinX', mapping: 'extent > minx'},
{name: 'MinY', mapping: 'extent > miny'},
{name: 'MaxX', mapping: 'extent > maxx'},
{name: 'MaxY', mapping: 'extent > maxy'}
])
});
//Create the grid.
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: "Spatial Reference", width: 240, dataIndex: 'SR', sortable: false},
{header: "Min-X", width: 120, dataIndex: 'MinX', sortable: false},
{header: "Min-Y", width: 120, dataIndex: 'MinY', sortable: false},
{header: "Max-X", width: 120, dataIndex: 'MaxX', sortable: false},
{header: "Max-Y", width: 120, dataIndex: 'MaxY', sortable: false}
],
renderTo: 'example-grid',
width: 720,
height: 400
});
store.load();
});
What I'd like to do is dispay each attributes/attribute tag in a different column. How does the xpath work?