I am trying to setup an administrative page so that users may log in and upload a file that will replace an existing file and also replace an existing link on a different web page(Flash) that draws its content from an XML file.
The user selects a file to upload. Selects a directory to upload the file to($location). And selects a name for the file($newname).
Once the file is uploaded (via PHP) the PHP script also sends information to the XML file.
The information sent to the XML file is a link generated by the information entered: $urlroot/$location/$newname
Reference:
$urlroot = www.mydomainname.com
$location= the directory that they have selected
$newname= the new name that they have given the file
The problem I run into is that when PHP sends the information to XML it has problems because of the special characters…
This is the PHP code that I have to send to XML:
$xml = simplexml_load_file("links.xml");
$sxe = new SimpleXMLElement($xml->asXML());
$links = $sxe->addChild("$location");
$links->addChild(“link”,“<![CDATA[<a href='$urlroot /$location/$newname'>$linkname</a>]]>");
$sxe->asXML("links.xml");
This is what shows up in the XML file (it already had the “links” node and I’ve edited the layout to make it easier to read, it actually comes out all on one line):
<?xml version="1.0" encoding="utf-8"?>
<links>
<TestingDirectory>
<link>
<![CDATA[<a href='"http://www.mydomain.com/testing/TestingDirectory/newLink.html"'>newLink.html</a>]]>
</link>
</TestingDirectory>
</links>
As you can see the <'s and >'s don't appear...
Basically what I’m trying to figure out is how to have php send the link to xml in a new node called link inside of a new node determined by $location and then have Flash pull that information and create a link on the webpage.
I have figured out how to load the XML into a Flash dynamic text field, just can't get PHP to send the link to XML correctly...
Please help if you can...
Best Regards,
Alex