all groups > flash data integration > march 2006 >
You're in the

flash data integration

group:

XML: Multiple Parent Nodes and DataSets?


XML: Multiple Parent Nodes and DataSets? Moztof
3/24/2006 2:22:59 PM
flash data integration:
I am using one DataSet for my entire project. Each Time I load a new XML file
into it I clear the DataSet. So things have been working rather nice and smooth
using one parent node. I have a question concerning multiple parent nodes and
one DataSet. Here is an example of my XML file:

<?xml version="1.0"?>
<albums>
<album AlbumTitle="Road Trip" DateReleased="08/01/1998"
AlbumImg="RoadTrip_Large.png"/>
</albums>

<tracks>
<track TrackID="1" TrackNum="1" TrackName="Watering Hole"/>
<track TrackID="2" TrackNum="2" TrackName="Solitude"/>
</tracks>


Here is an example of my XML code:

var AlbumsXML:XML;
var AlbumsXML:XML = new XML();
_root.AlbumsXML.ignoreWhite = "true";
_root.datads_Container.disableEvents();
_root.datads_Container.removeAll();
_root.AlbumsXML.onLoad = xmlPopDsJEA;
_root.AlbumsXML.load("Albums.xml");
function xmlPopDsJEA(){
numRow = _root.AlbumsXML.childNodes.length
//trace (numRow);
for(i = 0; i < numRow; i++){

//trace (i);
//trace(_root.AlbumsXML.childNodes.childNodes.length)
if(_root.AlbumsXML.childNodes.childNodes.length > 0){
trace(_root.AlbumsXML.childNodes.nodeName)
cNodesNum = _root.AlbumsXML.childNodes.childNodes.length;
for(j=0; j < cNodesNum; j++){
var newRow:Object = new Object();
//trace( _root.AlbumsXML.childNodes.childNodes.nodeName);
var Map = _root.AlbumsXML.childNodes.childNodes.attributes
for(var key in Map){
//trace("\t" + key + '=' + Map);
newRow=];
}
_root.datads_Container.addItem(newRow);
}
}

}
_root.datads_Container.enableEvents();
}

I have another MovieClip that attaches movies to a ScrollPane. I need to
differentiate, in another movie, what parent nodes to use. Here is the code to
attach the movie clips.

//goto first data set record
_root.datads_Container.first();
//var MoveiHeight = 0;
_root.amiValue = addMovieClips(0);

function addMovieClips(ami) {
while (_root.datads_Container.hasNext()) {
attachMovie("AlbumsListTarget", "AlbumsList"+ami, getNextHighestDepth(),
_root.datads_Container.currentItem);
ami++;
_root.datads_Container.next();
}

return ami;

}

stop();

Basically, I need an if statement that will look for the parent node names.
For some reason I can't get to that information.
I guess the code could look something like this:

function addMovieClips(ami) {
while (_root.datads_Container.hasNext()) {
If((_root.datads_Container.THEPARENTNODENAME ==
'TRACKS'){
attachMovie("AlbumsListTarget", "AlbumsList"+ami, getNextHighestDepth(),
_root.datads_Container.currentItem);
ami++;
}
_root.datads_Container.next();
}

Perhaps there is a better approach to this. Any help is appreciated.

Re: XML: Multiple Parent Nodes and DataSets? Moztof
3/24/2006 6:35:13 PM
I wrote out my XML file wrong. It should look like this...

<?xml version="1.0"?>
<albums>
<album AlbumTitle="Road Trip" DateReleased="08/01/1998"
AlbumImg="RoadTrip_Large.png"/>
<track TrackID="1" TrackNum="1" TrackName="Watering Hole"/>
<track TrackID="2" TrackNum="2" TrackName="Solitude"/>
</albums>

AddThis Social Bookmark Button