View Full Version : How to read attribute values of XML tag using XmlReader

30 May 2007, 7:39 AM
I am trying to use XmlReader to read an XML file and store it in the data store. However, I cannot figure out how to read the parameter of a certain tag in XML file.

My XML file is structured as follows:

<row num = "1">
<row num = "2">

And I am trying to use the following code to read values of "num" attribute and "name" tag out and store them into data store. However, I cannot figure out what I should put in the mapping part. (:| Thanks for a lot. (BTW, where can I find a good document for Ext.DomQuery except http://www.jackslocum.com/blog/2007/01/11/domquery-css-selector-basic-xpath-implementation-with-benchmarks/)

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/blabla.xml'}),
reader: new Ext.data.XmlReader({
record: 'row',
id: 'number'
// cannot figure out what should be put in the mapping
{name: 'number', type: 'int', mapping:'?????'},
{name: 'name'},

30 May 2007, 8:27 AM
Have you read the documentation on XmlReader?

30 May 2007, 8:29 AM
id: '@num'

It's an attribute, not a tag "<number>"

30 May 2007, 9:10 AM
Have you read the documentation on XmlReader?
Thanks Animal. I finally figure out the magic with your help. I did read the document for XmlReader and DomQuery. And I would really appreciate if you can point out where I can find "@" is used for reading tag attribute. I just cannot find it. :(

30 May 2007, 10:09 AM
Look for the blog entry on jack's old website, jackslocum.com.

Also, just play around with DomQuery on the Firebug console command line just to see what it can do. You can poke around to find what works quite easily with Firebug.