# Php \> xml \> flash

**URL:** https://forum.kirupa.com/t/php-xml-flash/65905
**Category:** Uncategorized
**Created:** [September 30, 2004, 2:49pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905 "2004-09-30T14:49:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![amigo\_largo](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@amigo\_largo](https://forum.kirupa.com/u/amigo_largo)
#### Post date: [September 30, 2004, 2:49pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/1 "2004-09-30T14:49:40Z")

</div>

Hi. I´m new here. It looks good!

I have written a php script that outputs xml, in order to load that into flash. My problem is, when using the XML object, or loadVars object to call the php script, in only loads the contents of the script itself, and not its output into flash…

do i need to open an XML socket here, or is there some other way of passing the output of the script to flash?

thanks.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 30, 2004, 3:20pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/2 "2004-09-30T15:20:10Z")

</div>

if you could give a url to the php script, and a piece of code how you load it up…

that would give us something to search at…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 30, 2004, 3:28pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/3 "2004-09-30T15:28:04Z")

</div>

```auto
<?php

$directory = 'images';
$resc = opendir($directory);
if (!$resc) {
	echo "Problem opening directory $directory. Error: $php_errormsg";
	exit;
}
$images = array();
while ($filename = readdir($resc)) {
	if (is_file($directory . '/' . $filename)) {
		$images[] = $filename;	// Add to the array
	}
}

echo "
<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";

echo "<books>";
echo "<club_del_misterio>";

$cnt = count($images);
for ($i = 0; $i < $cnt; $i++) {
	    echo "<book file=\"" . $images[$i]."\" />"; // Display filename or do whatever

}

echo "</club_del_misterio>";
echo "</books>";

?>

```

there´s your php, i was asking theoretically, in terms of what is the best practice in this situation. This just thows up a well formed xml doc. As I said before, the loadVars object and xml object only load in the contents of the script, and not the output.

thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 30, 2004, 4:40pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/4 "2004-09-30T16:40:25Z")

</div>

> and a piece of code how you load it up…

please…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 30, 2004, 6:47pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/5 "2004-09-30T18:47:17Z")

</div>

I ran into a problem sort of like this. I needed to put this code in:

header(“Content-type: text/xml”);  
echo “  
\<?xml version=“1.0” encoding=“ISO-8859-1” ?\>”;

_shrug_ maybe that will work?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 4, 2004, 5:08pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/6 "2004-10-04T17:08:40Z")

</div>

thanks. removed the /n from the xml declaration and now doesn’t throw up any error in firefox.

still doesn’t laod into flash tho ☹

will look at this later, working on four things at once!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 4, 2004, 5:55pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/7 "2004-10-04T17:55:34Z")

</div>

try this:

```php

myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("path_to_php_file.php");
myXML.onLoad = function(){
  readXML(this);
}
function readXML(xmlFile){
  trace(xmlFile)
}

```

that should work…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 4, 2004, 7:21pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/8 "2004-10-04T19:21:00Z")

</div>

same as before mate.

a -6 status code, which means a non-formed xml doc, which points to the possibility of it loading the php contents rather then the xml…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 4, 2004, 8:38pm UTC](https://forum.kirupa.com/t/php-xml-flash/65905/9 "2004-10-04T20:38:17Z")

</div>

```php

myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("http://work.longmate.net/dev/php/read_dir.php");
myXML.onLoad = function(){
  readXML(this);
}
function readXML(xmlFile){
  trace(xmlFile.firstChild.firstChild.childNodes[4])
} 

```

copy paste THAT !!! 😛

it should return:

> 

edit:  
conclusion: just ignore the error code and start using it ! 🙂

edit2:

```php

myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("http://work.longmate.net/dev/php/read_dir.php");
myXML.onLoad = function(){
  readXML(this);
}
function readXML(xmlFile){
	SubFolders = xmlFile.firstChild.childNodes
	for(i=0;i<SubFolders.length;i++){
		SubName = SubFolders*.nodeName;
		trace("Scanning folder: "+SubName);
		Books = SubFolders*.childNodes;
		for(ii=0;ii<Books.length;ii++){
			BookImage = Books[ii].attributes.file;
			trace(" - "+BookImage);
		}
	}
} 

```

see it works perfectly ! 🙂
