PDA

View Full Version : Parsing mixed XML



bandsitebuilder
3 Apr 2012, 7:47 AM
Hey all.. I'm new to Sencha (been a Flex dev for years) and trying to port over an existing app that relies heavily on XML.

To )simplify, I have an XML doc that I'm loading in that looks something like this



<machine>
<screens>
<screen>Test Screen</screen>
</screens>
<documents>
<document id="foo">MyDoc</document>
<document id="bar">My Other Doc</document>
</documents>
</machine>


I have set up two models, a "Document" and "Screens", as well as the appropriate Stores for each.

My question, what is the best approach to load this mixed node type XML in and create the appropriate models/stores.

As of right now, I'm loading a local XML file with an Ajax proxy and using an XML reader, but the XML reader only allows me to set a "root" and a "record". It seems that I can only set a single node name (either screens or documents) for the "record" attribute.

Is there a way I can go about this without having to load in the file twice with two different proxies?

mitchellsimoens
3 Apr 2012, 12:41 PM
Are you wanting to use associations or wanting to have the fields in the model be an object?

bandsitebuilder
3 Apr 2012, 1:32 PM
The data may or may not be related, I'm looking to parse the xml and create Document models from the Document nodes and Screen models from the screen nodes.

Does that make sense?