PDA

View Full Version : One Data Store in complex xml



bucka
22 Jul 2007, 5:16 PM
Hi.
I want to use only one DataStore to access a complex Xml, instead of using several stores.

My xml:


<areas>
<area>
<AREANAME>a1</AREANAME>
<Procedimentos>
<P>
<NAME>p1</NAME>
</P>

</Procedimentos>
</area>

<area>
<AREANAME>a1</AREANAME>
<Procedimentos>
<P>
<NAME>p1</NAME>
</P>
<P>
<NAME>p2</NAME>
</P>
</Procedimentos>
</area>
</areas>

IS it possible? I can only define one root..so how can i retrieve all 'P' tags?



var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: 'sheldon.xml'}),

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'area',

}, [

{name: 'AREANAME', mapping: 'AREANAME'}
])
});

thanks

utherwayn
30 Jul 2007, 5:42 PM
You would want to use Dom Query to select the correct records for your XML File.

http://extjs.com/deploy/ext/docs/output/Ext.DomQuery.html


If instead of using


record: 'area'


You use


record: 'P'


That will create a data store based on all P tags inside the entire document. You can specify further criterion by constructing what you need from the documentation provided at the above link.

Additionally, both record for the XML Reader and mapping for each column definitions allow a DOM Query as accepted input.

Hope this helps.