I am having a problem parsing xml data, I know how to get it into as3, and that is working pretty well after following a brilliant tutorial on kirupa: http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm
But I am having a problem tracing the data that I want. Seemingly it is connecting to the database and is working in that sense but when I try to trace data I am getting a couple problems.
The first is that I need to somehow specify a value of a single item to get the rest of the data. Here is the xml:
XML Code
<user>
<name>{$line[“name”]}</name>
<id>{$line[“id”]}</id>";
$query2 = “select * from circle where owner={$line[“id”]};”;
$result2 = mysql_query($query2) or die("Query failed2 : " . mysql_error());
while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC))
print "
<circle>
<id>{$line2[“id”]}</id>
<name>{$line2[“name”]}</name>
<ordinal>{$line2[“ordinal”]}</ordinal>
<pref>{$line2[“pref”]}</pref>
<colour>{$line2[“colour”]}</colour>
<comment>{$line2[“comment”]}</comment>
<question>{$line2[“question”]}</question>
<comment_viewed>{$line2[“comment_viewed”]}</comment_viewed>
<question_viewed>{$line2[“question_view”]}</question_viewed>
</circle>";
print “</user>”;
Now it seems that I need to input an ID for the user to be able to trace their circles/information so I tried using this as3 code to do this:
AS3 Code
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(“http://www.chaudiovisual.com/testing/show-user.php”));
function LoadXML(e:Event):void
{
xmlData = new XML(e.target.data);
Parse(xmlData);
//trace(xmlData);
}
function Parse(parse:XML):void
{
trace(“XML Output”);
trace("------------------------");
var userList:XMLList = parse.user;
for each (var userElement:XML in userList)
{
trace(userElement);
if (userElement.text() == 1)
{
trace(userElement.circle);
}
}
}
Can anyone help me out here?
Thanks in advance,
Conor