PDA

View Full Version : parsing nested XML: xml reader



dikshyant.pradhan
11 Aug 2012, 5:37 PM
Hi
I have an Xml response from server like,

<properties>
<property id=”123” name=”p1”>


<value name=”v1” attrb1=”12” />
<value name=”v3” attrb1=”12” />
<value name=”v4” attrb1=”12” />


</property>


<property id=”13” name=”p2”>


<value name=”v2” attrb1=”12” />

</property>

<properties>

I understand that using 'hasMany' config I can store the xml data into two models (say, Property & Value),only if the value elements are inside a <values> </values> tag. For example,

<property id=”123” name=”p1”>
<values>


<value name=”v1” attrb1=”12” />
<value name=”v3” attrb1=”12” />
<value name=”v4” attrb1=”12” />


</values>

</property>

But, my server response doesn't have this <values> tag and I can't modify the server response. Is there any way I can read my server response using xml reader?? or can i parse my xml response somehow OR modify it on client side before reading ??

Any help is appreciated... Thanks

mrsunshine
13 Aug 2012, 7:39 AM
You can define a mapping from XML structure path to model field see:

http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Field-cfg-mapping

dikshyant.pradhan
13 Aug 2012, 8:17 PM
Hi Thanks for replying.. But how can i map multiple records of that model to a specific record ? Could you specify an example.. Thanks again..