View Full Version : XML Document

1 Jun 2007, 6:14 AM
Say I have a document with structure like this:

<name>Customer X</name>
<email>[email protected]</email>

<address1>Some where</address1>
<city>Some City</city>

<address1>Right Here</address1>
<city>This City</city>

<name>ABC Widget</name>
<name>DEF Widget</name>

How can I intialize an Order object by reading 'order.xml' so that I can do below:

- Order.get('billing')
- Order.get('shipping')

- Order.get('products')
- Order.get('products').get(0)
- Order.get('products').size()

Further more, Ideally, I should also be able to use this object to make a master-child screen such that you may have a main tab with sub tabs such as Billing, Shipping etc., A grid that shows products ordered. etc.,

I think - This is a pretty common use case for many applications.

Given the generic nature of this use case, it should be fairly easy to create a generic Object which stores the abovementioned data structure - generically?

So each root node (such as customer, billing, shipping, products, product) etc., become, instances of this generic object?

Any thoughts? How does this sounds -

var objOrder = Ext.data.XMLObjectProducer(xmlDocURL); // Bad name perhaps, but.
var objBilling = objOrder.get('billing');
var arrProducts = objOrder.get('products');

for(arrProducts as objProduct){
// do something with objProduct

Generic object can provide simple set and get methods. Size methods for collection of objects will be useful.

I am looking for ideas as to how simple xml documents can be read, without learning too much about DomQuery etc.,

6 Jun 2007, 4:21 AM
did u get any solution about this..actually i am also on the same boat..i dunno hw to parse the XML and use .get('name') method...