View Full Version : Xml woes

2 Jul 2011, 12:45 PM
Hi All I have XML as below

<results hitCount="8">
<result pnum="22" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
killers BYLARRYMcSHANE DAILYNEWSSTAFFWRITER THEUPCOMINGROYALwedding is a <b>royal</b> pain for British security
<result pnum="21" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
’sBig Island based on a3-night stayat<b>Royal</b> Kona Resort. Caribbean valid for travel thru8/31/11; must be booked
<result pnum="59" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
, <b>ROYALS</b> 3(10): Pinch- hitter Shelley Duncan’s RBI double sparkedafour-run10thinningandvisiting Cleveland
<result pnum="75" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
Reina del Sur (ss) The First 48 (cc) Blue Planet: Seas of Life (cc) <b>Royally</b> Mad (N) (cc) Family Affair
<result pnum="65" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
<result pnum="63" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
. Pablos Cuevas,Uruguay,7-5, 3-6, 6-4. GrandPrixdeSARLaPrincesse LallaMeryem YESTERDAY’SRESULTS At<b>Royal</b>
<result pnum="64" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
-5 3-5 4-4 2-3 Indians 7, <b>Royals</b> 3(10) Cleveland Sizemorecf A.Cabrerass Choorf AB RH RBI BB SO Avg. 51
<result pnum="69" eid="71a5db25-b0a5-4872-aeb3-5a69d698aa2c" name="04/19/2011">
Louie'sLass MajorDixie RuleTheDay DeDanann RomanMaiden ForRealToo Fairly<b>Royal</b> 5th Horses 4-GrandCaptain 7

And a model as

var modsearchinfo = Ext.regModel('searchinfo', {
fields: [
{ name: 'pnum', mapping: '@pnum', type: 'string' },
{ name: 'eid', mapping: '@eid', type: 'string' },
{ name: 'name', mapping: '@name', type: 'string' },


I can pick up the values in the mapping but I want to pick up the values inside the brackets, ie first row - "killers BYLARRYMcSHANE DAILYNEWSSTAFFWRITER THEUPCOMINGROYALwedding is a <b>royal</b> pain for British security"

I have tried adding a result field without mapping but its a different level down so isnt picking up

Please help, please

3 Jul 2011, 7:30 PM
Try this override for XmlReader which just adds an extra check to see if the key (mapping) is '$self' and if so, it just graps the value directly from the root node.

Ext.override(Ext.data.XmlReader, {

createAccessor: function() {
var selectValue = function(key, root, defaultValue){
var node = (key === '$self') ? root : Ext.DomQuery.selectNode(key, root),
if (node && node.firstChild) {
val = node.firstChild.nodeValue;
return Ext.isEmpty(val) ? defaultValue : val;

return function(key) {
var fn;

if (key == this.totalProperty) {
fn = function(root, defaultValue) {
var value = selectValue(key, root, defaultValue);
return parseFloat(value);

else if (key == this.successProperty) {
fn = function(root, defaultValue) {
var value = selectValue(key, root, true);
return (value !== false && value !== 'false');

else {
fn = function(root, defaultValue) {
return selectValue(key, root, defaultValue);

return fn;


Then, add a field for your results and map it to '$self'

{field : 'results', mapping: '$self'}