actionscript:
var input_xml = new XML();
input_xml.ignoreWhite = true;
input_xml.contentType = "text/xml";
input_xml.onLoad = function(success){
if (success) input_txt.text = this.firstChild.firstChild.nodeValue;
else input_txt.text = "Error loading input XML";
}
var output_xml = new XML();
output_xml.ignoreWhite = true;
output_xml.onLoad = function(success){
if (success) output_txt.text = this.firstChild.firstChild.nodeValue;
else output_txt.text = "Error loading output XML";
}
var xml_file = "readwrite/simple_edit.xml";
var server_file = "simple_save.php";
load_btn.onRelease = function(){
input_txt.text = "Loading...";
input_xml.load(xml_file + "?uniq=" + new Date().getTime());
}
send_btn.onRelease = function(){
input_xml.parseXML("<edit> new text </edit>");
input_xml.firstChild.firstChild.nodeValue = input_txt.text;
input_xml.xmlDecl = ""; // declaration duplication bug
input_xml.sendAndLoad(server_file, output_xml);
output_txt.text = "Loading...";
}
clearin_btn.onRelease = function(){
input_txt.text = "";
}
clearout_btn.onRelease = function(){
output_txt.text = "";
}
my xml:
<?xml version="1.0"?><edit>This is meant to be edited</edit>
my php (although i think it’s an actionscript problem:
<?php
$filename = "readwrite/simple_edit.xml";
$raw_xml = file_get_contents("php://input");
print $raw_xml;
$fp = fopen($filename, "w");
fwrite($fp, $raw_xml);
fclose($fp);
?>
when I press the send button and change my text in the input_txt.text into
a node value with
input_xml.firstChild.firstChild.nodeValue = input_txt.text;
if my text includes <'s or >'s or any special characters, they get converted away, rendering my final xml product useless (with <'s there is no tags). Is there a way around this?
code is from kirupa’s http://www.kirupa.com/web/xml/examples/simpleeditor.htm awesome tutorial.
Any thoughts would be totally helpful,
Blake