PDA

View Full Version : parsing XML



Akansha
6 Jun 2007, 3:42 AM
Hi,

here is my code which i have written for getting the XML data ------

var RecordDef = Ext.data.Record.create([
{name: 'id'},
{name: 'name'},
{name: 'company'},
{name: 'cost'},
{name: 'desc'}

]);

var myReader = new Ext.data.XmlReader({
record: "row",
}, RecordDef);

var pidValue = RecordDef.get(company);
alert(pidValue);

XML is --
<?xml version="1.0" encoding="UTF-8"?>
<item>
<info>
<id>4</id>
<name>television</name>
<company>philips</company>
<cost>10000</cost>
<desc>color tv</desc>
</info>
</item>

i want to extract info from this XML.I am trying to do it with data record but unable to access it. Can u help in getting back the data.
Thanx in advance

John Sourcer
6 Jun 2007, 5:47 AM
var myReader = new Ext.data.XmlReader({
record: "row",
}, RecordDef);

var pidValue = RecordDef.get(company);
alert(pidValue);

XML is --
<?xml version="1.0" encoding="UTF-8"?>
<item>
<info>

Surely record: 'item' ?

Akansha
6 Jun 2007, 6:03 AM
i m nt sure...i did it coz for record is the item which is repeated...but there is no repeating item for my xml....

Animal
6 Jun 2007, 6:18 AM
Well, it's repeated once...