-
1. Re: How to read XML?
kglad Oct 23, 2009 8:20 AM (in response to TarunaR)use the following to retrieve the the first or second array of your image nodes:
yourxml.childNodes[1].firstChild.childNodes or
yourxml.childNodes[1].firstChild.nextSibling.childNodes
-
2. Re: How to read XML?
TarunaR Oct 23, 2009 11:04 AM (in response to kglad)Thank you for your reply. I understand what you are saying. The only issue is when we define
myxml.childNodes[1].firstChild.nextSibling.childNodes
we are restricting to the firstChild ie the first SET, i did mention if we have for example 5 sets, i dont want to keep on defining
myxml.childNodes[1].childNodes[0].childNodes
myxml.childNodes[1].childNodes[1].childNodes
myxml.childNodes[1].childNodes[2].childNodes
myxml.childNodes[1].childNodes[3].childNodes
myxml.childNodes[1].childNodes[4].childNodes
even if i place them in some loop, how to know the length of the childNodes?
-
3. Re: How to read XML?
TarunaR Oct 23, 2009 1:10 PM (in response to TarunaR)Just a further help needed
I modified everything but just need a minor help in figuring out why it is getting an error opening url.
code:-
for (i=1; i<imgs.childNodes.length; i++) {
for (a=0; a<imgs.childNodes[i].childNodes.length; a++){
nextImg["loc"+i] = imgs.childNodes[i].childNodes[a].attributes.url;
}
}
a = 0;toolTipMC.previous.onRelease = function() {
if (a>0) {
a--;
toolTipMC.img.imgHolder.loadMovie(nextImg[myBtn._name]);
if (a==0) {
toolTipMC.img.imgHolder.loadMovie(nextImg[myBtn._name]);
}
}}
toolTipMC.next.onRelease = function() {if (a<2) {
a++;toolTipMC.img.imgHolder.loadMovie(nextImg[myBtn._name]);
}
};
};XML: changed it completely. took the sets out of the tag images.
<data>
</data>
<imagesSet>
<image url="images/1.jpg"></image>
<image url="images/2.jpg"></image>
<image url="images/3.jpg"></image>
</imagesSet>
<imagesSet>
<image url="images2/1.jpg"></image>
<image url="images2/2.jpg"></image>
<image url="images2/3.jpg"></image>
</imagesSet>
<imagesSet>
<image url="images3/1.jpg"></image>
<image url="images3/2.jpg"></image>
<image url="images3/3.jpg"></image>
</imagesSet> -
4. Re: How to read XML?
kglad Oct 23, 2009 1:22 PM (in response to TarunaR)1 person found this helpfulif you'll have a varying number of imagesets you need to fix your xml:
<data>
</data>
<imageSets>
<imagesSet>
<image url="images/1.jpg"></image>
<image url="images/2.jpg"></image>
<image url="images/3.jpg"></image>
</imagesSet>
<imagesSet>
<image url="images2/1.jpg"></image>
<image url="images2/2.jpg"></image>
<image url="images2/3.jpg"></image>
</imagesSet>
<imagesSet>
<image url="images3/1.jpg"></image>
<image url="images3/2.jpg"></image>
<image url="images3/3.jpg"></image>
</imagesSet></imageSets>
-
5. Re: How to read XML?
TarunaR Oct 23, 2009 1:53 PM (in response to kglad)You got it right, now it is loading at least however just the last item from the imageSet. I named all of them respectively, imageSet1, imageSet2, imageSet3.
my code is the same. Please help :-(
-
6. Re: How to read XML?
kglad Oct 23, 2009 2:09 PM (in response to TarunaR)use:
for(var i=0;i<yourxml.firstChild.nextSibling.childNodes.length;i++){
for(var j=0;j<yourxml.firstChild.nextSibling.childNodes[i].childNodes.length;j++){
trace(i+" "+j+" "+yourxml.firstChild.nextSibling.childNodes[i].childNodes[j]);
}
} -
7. Re: How to read XML?
TarunaR Oct 26, 2009 10:02 AM (in response to kglad)Nopes,
You didnt get what i asked for.
see, once i click on a button, it should fetch the content from xml to the movieclip(toolTipMC) on the stage, movieclip(toolTipMC) have a start button, once we click on that, it should fetch the very first image from the respective set(loc1, loc2, loc3) underneath there is next and previous button, when clicked on the next it should bring the next image from the same set.
I am just stuck with the next and previous code.
for(i=0;i<imgs.firstChild.nextSibling.childNodes.length;i++){
for(a=0;a<imgs.firstChild.nextSibling.childNodes[i].childNodes.length;a++){nextImg["loc"+i] = imgs.firstChild.nextSibling.childNodes[i].childNodes[a].attributes.url;
}
a = 0;
toolTipMC.previous.onRelease = function() {
if (a>0) {
a--;
toolTipMC.img.imgHolder.loadMovie(nextImg[myBtn._name]); //myBtn._name are loc1, loc2, loc3
}
toolTipMC.next.onRelease = function() {newTotal = x.firstChild.nextSibling.childNodes[myBtn._name.charAt(3)].childNodes.length;
if (a<newTotal) {
a++;
toolTipMC.img.imgHolder.loadMovie(nextImg[myBtn._name]);}
-
8. Re: How to read XML?
TarunaR Oct 26, 2009 8:06 PM (in response to kglad)Hey thanks, however i got a way through. I did not run a second loop of j. I just divided myxml.firstChild.nextSibling.childNodes[i].childNodes[j] into two.
1. myxml.firstChild.nextSibling.childNodes[i].childNodes2. [j]
so passing j value via my click and adding to my 1st.