View Full Version : xml problem.. need help...
i have a xml file like :
<GUEST>
<USER name="John" age="20"/>
<USER name="Joey" age="19"/>
</GUEST>
in flash :
xmlNode = new XML();
usernode = xmlNode.createElement("USER");
usernode.attribute.name = "Mary";
usernode.attribute.age = "19";
xmlNode.firstChild.appendChild(usernode);
i tried to add another node to this xml file.... but it can't work.
So have anyone know how to solve it?
freddycodes
02-04-2003, 08:23 PM
Its attributes not attribute
xmlNode = new XML();
usernode = xmlNode.createElement("USER");
usernode.attributes.name = "Mary";
usernode.attributes.age = "19";
xmlNode.firstChild.appendChild(usernode);
But do you want to then add USER to your GUEST XML?
sorry... i typed wrong...
my code is using attributes....
it need php?
freddycodes
02-04-2003, 09:50 PM
it need php?
I am not sure what you are asking.
i mean need to use php or asp to add that node?
like:
xmlNode = new XML();
usernode = xmlNode.createElement("USER");
usernode.attributes.name = "Mary";
usernode.attributes.age = "19";
xmlNode.firstChild.appendChild(usernode);
xmlNode.send("xx.php");
but i'm not familiar with php and asp.....
freddycodes
02-04-2003, 10:24 PM
So does flash even play a part in this or was that just an example?
i found this from a website... can anyone explain that php code?
Flash:
on (release) {
loginXML = new XML();
loginElement = loginXML.createElement("LOGIN");
loginElement.attributes.username = "MyDog";
loginElement.attributes.password = "barkbark";
loginXML.appendChild(loginElement);
loginXML.contentType = "text/xml";
loginReplyXML = new XML();
loginReplyXML.onLoad = onLoginReply;
loginXML.sendAndLoad("xmlreader.php", loginReplyXML);
}
xmlreader.php PHP CODE:
<?
$filename = "xmloutput.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "$HTTP_RAW_POST_DATA" );
fclose( $fp );
print '<?xml version="1.0"?><result>LOGIN OK</result>';
?>
freddycodes
02-05-2003, 01:41 AM
<?
$filename = "xmloutput.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "$HTTP_RAW_POST_DATA" );
fclose( $fp );
print '<?xml version="1.0"?><result>LOGIN OK</result>';
?>
All that does is take the xml sent from flash and writes it to a text file, then replies with a repsonse message to flash. Is the xml file you want to add to on the server?
All that
then have any way and how to use php to get my lastChild node and write a new node behind it??
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.