# XML Calendar Works, But How

**URL:** <https://forum.kirupa.com/t/xml-calendar-works-but-how/262166>\
**Category:** flash\
**Created:** [June 3, 2008, 9:02pm UTC](https://forum.kirupa.com/t/xml-calendar-works-but-how/262166 "2008-06-03T21:02:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![setzer9999](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@setzer9999](https://forum.kirupa.com/u/setzer9999)\
**Post date:** [June 3, 2008, 9:02pm UTC](https://forum.kirupa.com/t/xml-calendar-works-but-how/262166/1 "2008-06-03T21:02:09Z")

</div>

I have the following code in actionscript

```auto

var calendar:XML = new XML();
calendar.ignoreWhite = true;

var captions:Array = new Array();

calendar.onLoad = function(success) {
    if (success) {
        var rootNode = this.firstChild;
        for (var aNode:XMLNode = rootNode.firstChild; aNode != null; aNode=aNode.nextSibling) {
            captions.push(aNode.firstChild.nodeValue);
        }

		caption.htmlText = captions[0];
		
    } else {
        trace("XML not loaded");
    }
};

       day1.onPress = function() {
            caption.htmlText = captions[0];
        };

        day2.onPress = function() {
            caption.htmlText = captions[1];
        };

```

Which references the code in an XML document:

```auto

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<slideshow>

	<caption>

<![CDATA[<p>January 1, 2009.</p>
<p>Happy New Year!</p>]]>

</caption>

	<caption>

<![CDATA[<p>January 2, 2009.</p>
<p>No events Scheduled</p>]]>

</caption>

</slideshow>

```

Everything works perfectly! Finally! I stole the code from people who helped me, but it didn’t work with my specific setup as was… but all the help I got in people telling me a bunch of different codes made me slowly learn how parents, children, and nodes work! I fixed the parameters, and it functions and I know why! Thank you all very much.

The only small, tiny part of the code I don’t understand is the following:

anode=anode.nextSibling

as found in the for condition in the code above

I don’t understand how the application knows which sibling to go to next. I add the number of the child in brackets like so

caption.htmlText = captions[2]

How does the anode=anode.nextSibling code determine which node information is displayed due to this? Please! I need to understand what I’ve done, not just do it.
