PDA

View Full Version : xml type question


toshesh
06-04-2003, 02:32 AM
Hi everyone,

I'm having trouble reading data from a php file, which echos some data in an xml format.

print "<dataset>";
$row = pg_fetch_row($result, 0); //connection part abbreviated
print "<data>";
print "<rownum>1</rownum>";
print "<kid>". $row[0] ."</kid>";
print "<mname>". $row[1] ."</mname>";
print "<gtype>". $row[2] ."</gtype>";
print "</data>";

print "</dataset>";

on the flash side the code should start working when i press a button but nothing seems to be occur. How can I read the data entered from php and display it in flash????

on (release) {
include("php_xml_hander.as");
dataXML = new XML();
dataXML.onLoad = convertXML;
dataXML.load("sendxml.php");
}

function convertXML() {

mainTag = new XML();
elementTag = new XML();
dataList = new Array();
elementList = new Array();
dlist = new Array();
mainTag = this.firstChild;

if (dataXML.loaded) {
if (mainTag.nodeName == "dataSet") {
dataList = mainTag.childNodes;
for (i = 0; i < dataList.length; i++) {
if (dataList[i].nodeName == "data") {
elementList = dataList[i].childNodes;
for (j = 0; j < elementList.length; j++) {
elementTag = elementList[j];
elementType = elementTag.nodeName;

if (elementType == "rownum")
rownum = elementTag.firstChild.nodeValue;

if (elementType == "kid")
kid = elementTag.firstChild.nodeValue;

if (elementType == "mname")
mname = elementTag.firstChild.nodeValue;

if (elementType == "gtype")
gtype = elementTag.firstChild.nodeValue;
}
// Adds the label and data to the URL.
dlist.push(rownum, kid, mname, gtype);
}
}
}
}
}

spriggan
06-05-2003, 09:19 AM
Here are some usefull Turorials
http://www.kirupa.com/developer/actionscript/scripting.htm

fgf
06-05-2003, 12:18 PM
I notice you are missing

dataXML.ignoreWhite=true;

which will cause no end of problems.

Also if you put a trace in your onload handler function is it called?

fgf