Display XML from a called php script

The php script is creating a list of files in my specified directory.
Now I am trying to create actionscript to call the php script and display the xml results.  I have found scripts for value separated scripts... but none for xml.   Anybody done this?  Code examples appreciated.

Yes this a script I am running local FYI (I have wamp server)

Thanks much
<?php // select the directory to list

$path = "file:///C:/evolve/";



// Initalise some variables

$output_string = '';

$file_number = 0;



// Get the directory handle

$dir = dir( $path ); 

// Read all files / dirs in the directory

print "<?xml version=\"1.0\"?>\n";

print "<myMenu>\n";

while ( false !== ( $file_name = $dir->read() ) ) { 



        // Exclude this dir and parent dir

        if( $file_name[0] != '.' ){

                // Add file to the output string

                //$output_string .= "&file_" . ++$file_number . "=" . urlencode( $file_name );

				print "<file>".$file_name."</file>\n";

				//print $file_name."<br>";

        }



} 

print "</myMenu>";

$dir->close();
?>

Open in new window

bowerdesignAsked:
Who is Participating?
 
CyanBlueCommented:
If you do this, all the content of the file nodes will be pushed into the file_arr which you can use later on...

CyanBlue
var file_arr:Array = new Array();

var _xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = function(loaded)
{
	if (loaded)
	{
		parseXML(this);
	}
};
_xml.load("LoadXMLAS2.xml");

function parseXML(xml:XML)
{
	var node = xml.firstChild.childNodes;
	for (var a = 0; a < node.length; a++)
	{
		file_arr.push(node[a].firstChild);
	}
	
	trace("file_arr = " + file_arr);
}

Open in new window

0
 
CyanBlueCommented:
What version of ActionScript do you use???
What is the XML output from that PHP script???

CyanBlue
0
 
bowerdesignAuthor Commented:
Thanks for looking!

AS2

<myMenu>
<file>client1.project_2.site_001.xml</file>
<file>client1.project_2.site_002.xml</file>
<file>client1.project_2.site_003.xml</file>
<file>Copy of client1.project_2.site_003.xml</file>
</myMenu>
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
CyanBlueCommented:
Try something like this...

CyanBlue
var _xml = new XML();
_xml.onLoad = function(loaded)
{
	if (loaded)
	{
		trace(this);
	}
}
_xml.load("pathTo.php");

Open in new window

0
 
bowerdesignAuthor Commented:
Hey Cyan
I changed to this:
var _xml = new XML();
xmlData.ignoreWhite = true;
_xml.onLoad = function(loaded)
{
      if (loaded)
      {
            trace(this);
            testFiles.text = (this);
      }
}
_xml.load("xmlDirectory.php");
----------------------------------------------------------------------------

AND... I got this for swf output:

<?xml version="1.0"?>



client1.project_2.site_001.xml
client1.project_2.site_002.xml
client1.project_2.site_003.xml
Copy of client1.project_2.site_003.xml


----------------------------------------------------------------

Now I just need to strip the files out from the xml ?nodes?.
Y/N
0
 
bowerdesignAuthor Commented:
Awesome, that gets me on the road.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.