PQAlex Posted July 28, 2009 Share Posted July 28, 2009 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 know how to load the XML into Flash just can't seem to figure out how to pass the link from PHP to XML properly... Please help if you can... Thanks, Alex Link to comment https://forums.phpfreaks.com/topic/167872-send-link-from-php-to-xml-need-help-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.