# Maybe impossible XML?

**URL:** <https://forum.kirupa.com/t/maybe-impossible-xml/204815>\
**Category:** flash\
**Created:** [October 23, 2006, 7:29pm UTC](https://forum.kirupa.com/t/maybe-impossible-xml/204815 "2006-10-23T19:29:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 23, 2006, 7:29pm UTC](https://forum.kirupa.com/t/maybe-impossible-xml/204815/1 "2006-10-23T19:29:16Z")

</div>

Anyway it soon kills me here in Sweden. And so does the cold weather coming in… ☹

Let me first try to explain my layout. I have a index.swf loading all my external swf. That works fine. Then all of my **main categories folders** are named **main1** , **main2** , **main3** etc. Inside of the main folders I have **image folders** containing my images for the different sub sections ( **image1** , **image2** , **image3** etc) and swf’s for each **sub sections** in my main categories named **sub1.swf** , **sub2.swf** , **sub3.swf** etc which loads images using XML. It’s in these sub.swf’s my problem resides, I think. My problem is how to get my different swf’s to read only the data intended for each sub section. Puh!

I think it has to do with **…childNodes.childNodes[1]…** and so on which I can’t figure out.

A under construction example of the site can be seen here: [http://www.gregory.se/heja.html](http://www.gregory.se/heja.html)

What I’m trying to accomplish is to control the loading of images to the different sub sections using **only one XML** file that looks like this (in short version);

**XML file:**

```php

<?xml version="1.0" encoding="iso-8859-1" ?>

<xmlData>
	<main>
		<subnumber>
			<subinfo>
				<path>main1/images1/01.jpg</path>
				<info><![CDATA[<p>main1, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main1/images2/01.jpg</path>
				<info><![CDATA[<p>main1, sub2</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main1/images2/02.jpg</path>
				<info><![CDATA[<p>main1, sub2</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
	<main>
		<subnumber>
			<subinfo>
				<path>main2/images1/01.jpg</path>
				<info><![CDATA[<p>main2, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main2/images1/02.jpg</path>
				<info><![CDATA[<p>main2, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main2/images2/01.jpg</path>
				<info><![CDATA[<p>main2, sub2</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
	<main>
		<subnumber>
			<subinfo>
				<path>main3/images1/01.jpg</path>
				<info><![CDATA[<p>main3, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main3/images1/02.jpg</path>
				<info><![CDATA[<p>main3, sub1</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
<xmlData>

```

**In my sub.swf’s I have this code:**

```auto

var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild;
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")

```

---

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 23, 2006, 7:43pm UTC](https://forum.kirupa.com/t/maybe-impossible-xml/204815/2 "2006-10-23T19:43:59Z")

</div>

I myself tried this, without luck but please anyone tell me if I’m on right track or not…

```auto

var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild[0];
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes[0].childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes[0].childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")

```

---

<div class="post-metadata">

**Author:** ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)\
**Post date:** [October 23, 2006, 10:04pm UTC](https://forum.kirupa.com/t/maybe-impossible-xml/204815/3 "2006-10-23T22:04:54Z")

</div>

Looks like this when working for each sub.swf I have to change the **[0] in the second childNode in my xmlData var** to whatever node I wish to start on.

```auto

var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild.childNodes[0].childNodes[0];
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")

```
