View Full Version : Character Escaping for data models

25 Feb 2013, 11:28 AM
I'm trying to set up a data model for Ext's grid widget. My document is an XML document of the following format:

<value1>some text</value1>

<value2>some text</value2>

<entry xyz:creationDate="2013-02-25" abc:author="John">

<title> Some title </title>

<relevance:score> 10.0 </relevance:score>


I am trying to get the value for xyz:creationDate and relevance:score. My current model looks like:

extend: 'Ext.data.Model',
fields: [
'title', 'relevance\:score', {name: 'xyz:creationDate', mapping:'@xyz:creationDate'},

Unfortunately, I receive an error for the relevance score of "Object has no method 'score'" and I get no results for the creationDate.

How can I escape the colon for the relevance score and get results for the creation date?

Thanks for the help,

26 Feb 2013, 8:01 AM
So I was able to figure out a partial solution. It turns out that the issue is not with escaping a character. Rather, the issue is with XML namespaces. In this case, it appears that Ext removes the namespaces. I was able to access the relevance:score value simply by removing "relevance:" from the mapping.

I tried extending this solution to collecting the creationDate, but had not luck. The mapping for the date was changed from {name: 'xyz:creationDate', mapping:'@xyz:creationDate'} to {name: 'Date', mapping: '@creationDate'} but still produces no results.