View Full Version : parse xml file

9 Feb 2011, 8:39 AM

I am trying to parse an xml file (see the end of this text)using xmlreader and show the results in a grid.This is a piece of code i use:
var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({ url: 'xxxx.xml' }),
reader: new Ext.data.XmlReader({
record: 'sld:ColorMapEntry ',
totalRecords: 'result'
}, [
{name: 'Color', type: 'string', mapping:'@color' },
{name: 'Opacity', type:'float', mapping:'@opacity' },
{name: 'Value', type: 'float', mapping:'@quantity' }
var grid = new Ext.grid.GridPanel({
store: ds,
columns: [
{ header: "Color", width: 120, dataIndex: 'color', sortable: true },
{ header: "Opacity", width: 180, dataIndex: 'opacity', sortable: true }

renderTo: 'mygrid',
width: 540,
height: 200
What I get is an empty grid.
Any help?

<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<sld:ColorMap color="#FFFFFF" opacity="0" quantity="-9999">
<sld:ColorMapEntry color="#FFFFFF" opacity="0" quantity="-9999"/>
<sld:ColorMapEntry color="#A9F5A9" opacity="0.5" quantity="1"/>
<sld:ColorMapEntry color="#FA5858" opacity="0.5" quantity="7"/>