PDA

View Full Version : [2.0b1]xmlReader How to map a parent node of the Record?



ckr
25 Oct 2007, 1:27 PM
The XML looks like:



<Director id="FA-4D">
<Port number="0"
node_wwn="5006048C48587853"
server_count="0"
device_count="0"
switch_name="-"
switch_interface="-"
switch_vsan="-">
<Fibre_Flags volume_set_addressing="Disabled"/>
</Port>
<Port number="1"
node_wwn="5006048C48587873"
server_count="0"
device_count="0"
switch_name="-"
switch_interface="-"
switch_vsan="-">
<Fibre_Flags volume_set_addressing="Disabled"/>
</Port>
</Director>
<Director id="FA-13D">
<Port number="0"
node_wwn="5006048C4858785C"
server_count="0"
device_count="0"
switch_name="-"
switch_interface="-"
switch_vsan="-">
<Fibre_Flags volume_set_addressing="Disabled"/>
</Port>
<Port number="1"
node_wwn="5006048C4858787C"
server_count="0"
device_count="0"
switch_name="-"
switch_interface="-"
switch_vsan="-">
<Fibre_Flags volume_set_addressing="Disabled"/>
</Port>
</Director>


The xmlReader is:


var myXMLReader = new Ext.data.XmlReader(
{
record: 'Port',
}, [
{name: 'Dir', mapping: '[email protected]'},
{name: 'Port', mapping: '@number'},
{name: 'WWN', mapping: '@node_wwn'},
{name: 'ServerCnt', mapping: '@server_count'},
{name: 'DevCnt', mapping: '@device_count'},
{name: 'swName', mapping: '@switch_name'},
{name: 'swInt', mapping: '@switch_interface'},
{name: 'swVsan', mapping: '@switch_vsan'},
{name: 'vsa', mapping: '[email protected]_set_addressing'}
]
);



This will get every port record, but will not include the [email protected] attribute.

So my repeating element is Port. However, would like each Port record to contain the Parent Node id attribute ([email protected]). This would seem to be a simple mapping of the parent node of each port.

Probably a rookie mistake, or my searching skills of the forums and docs are not elite enough.
Anyone have any ideas?
Thanks in advance!

Animal
25 Oct 2007, 1:34 PM
Try this extension to XmlReader. You specify mapping as a function which may use DomQuery to grab whatever data you want out of the document.

http://extjs.com/forum/showthread.php?p=21156#post21156

ckr
26 Oct 2007, 4:14 AM
Ah yes, I saw that thread earlier, and I will give that a shot.

Guess I am just surprised that there isn't some similar notation as to "../@id" which works when applying XSLT.

Thanks for the input!