View Full Version : XML Selection with Multiple Elements in a single record

27 May 2010, 1:11 AM
Hi I have a grid which has been populated from an XML Store, which reads from the following XML file:

<widget id="TextInput">
<widgetDescription>Custom textfield which allows parameterized properties</widgetDescription>
<parameters id="TextInput">
<loadparams id = "renderTo" value = "widgetView" />
<loadParams id = "hidden" value = "false" />
<loadParams id = "disabled" value = "false" />
<loadParams id = "name" value = "testName" />
<loadParams id = "fieldLabel" value = "testLabel" />


<widget id="TestWidget">
<widgetDescription>New Test Widget using re-written template</widgetDescription>
<parameters id="TestWidget">
<loadParams id="renderTo" value = "widgetView"/>

Here is the Store:

var widgetListStore = new Ext.data.XmlStore
storeId : 'widgetListStore',
url : window.WIDGETROOT+"/widgetList.xml",
autoLoad : true,
record : 'widget',
id : 'widgetXMLreader',
fields : [{
name : '_widgetId',
mapping : '@id'
name : '_widgetName',
mapping : 'wname'
name : '_widgetAuthor',
mapping : 'author'
name : '_widgetDescription',
mapping : 'widgetDescription'
name : '_loadURL',
mapping : 'loadURL'

name : '_objectName',
mapping : 'objectName'

name : 'params',
mapping : 'parameters'


The grid to which this store populates contains a listener (click) which passes all the values for each record to a function (apart from the parameters). However, my issue is as follows. I need to create the ability to pull out the <parameters> element for each record and iterate over each of the <loadParams> elements pulling out their respective attributes of id and value. I have tried several methods such as creating a new reader just for the parameters tag, and even a new store, but I always end up with a semi-success. I am able to get all <loadParams> element attributes for all <parameter> elements for every record, but what I wish to get is only those elements based on one particular record at a time.

I am able to get at the <widget> id attribute and have ensured that the corresponding <parameters> element has the same id. My main problem boils down to the record property for either an XML reader, or XmlStore. What I would like to do in theory is to specify the record property as something akin to :

record : parameters[[email protected]]
Now , in my function I am able to get the widget id for the selected record and thus the "[email protected]" can be replaced with the relevant variable containing the value. Sadly this does not work, for whatever reason. I am stuck in a rut. I have spent two days traversing the ext forums, and google for an answer, and trying to interpret a multitude of cryptic or ambiguous q&a's from Ext forum and wider. The API is not much more enlightening either, a problem which is compounded by awfully small amount of overly complex examples, which I as a fairly new Ext and XML user find a little frustrating.

I stumbled across the domQuery which looks promising, but despite going over the tutorials and the Api's doesn't seem to give any clear examples of working with XML in this case, mainly HTML CSS, and JSON. The API lacks any examples in fact, its good to know what it does but it would be better to see how to do it!

Is any soul out there willing to help? it would be much appreciated. Also, if it is at all possible, I would appreciate avoiding links to the API, and other such one-line directions, I know where the API is thank you and I am in the process of deciphering it for this issue. I work more by doing than saying, so examples are greatly welcomed!

Thanks in Advance