halfer2008 Posted May 19, 2008 Share Posted May 19, 2008 Hi Im making a simple xml cms to use on my site, doesn't have to be secure or anything but encountered a problem with a / appearing before every ' i use in the text. Anyway my code is as follows: content.php <?php // set name of XML file $file = "content.xml"; // load file $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); // access XML data echo "Content: " . $xml->text . "\n"; $textContent = $xml->text; ?> <form action="save.php" method="post" > <textarea name="text" value="text"><?=$textContent;?></textarea> <input type="submit" /> </form> and save.php <?php // set name of XML file $file = "content.xml"; // load file $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); $text = $_POST['text']; // modify XML data $xml->text = $text; // write new data to file file_put_contents($file, $xml->asXML()); echo "Content: " . $xml->text . "\n"; ?> Could someone run through with mehow I'd replace the ' and special characters on the way in and then get them back on the way out of the xml? Kind Regards & Thanks in advance Chris Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/ Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 $text = stripslashes($_POST['text']); Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544777 Share on other sites More sharing options...
halfer2008 Posted May 19, 2008 Author Share Posted May 19, 2008 Thats great problem now is that im using TinyMCE as the text editor for the cms, everything works fine except for the Ordered and Unordered Lists, any ideas? Kind Regards Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544795 Share on other sites More sharing options...
nadeemshafi9 Posted May 19, 2008 Share Posted May 19, 2008 look at the html of the content by adding the html view button to tinymce and see what is wrong with the markup Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544803 Share on other sites More sharing options...
halfer2008 Posted May 19, 2008 Author Share Posted May 19, 2008 Its to do with the lis etc and nbsp when it goes to load in the xml. Is there a way I can make that stuff xml while also curing the problem i solved by use of the stripslashes? Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544824 Share on other sites More sharing options...
nadeemshafi9 Posted May 19, 2008 Share Posted May 19, 2008 Its to do with the lis etc and nbsp when it goes to load in the xml. Is there a way I can make that stuff xml while also curing the problem i solved by use of the stripslashes? stripslashes is an amturish way of solving problems like these, u are stripping the slashes of XML Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544858 Share on other sites More sharing options...
halfer2008 Posted May 19, 2008 Author Share Posted May 19, 2008 Is there another way that you could recommend nadeemshafi9? My understanding is that Im striping the /s from the code before it goes into the xml, not actually striping the xml. Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544861 Share on other sites More sharing options...
nadeemshafi9 Posted May 19, 2008 Share Posted May 19, 2008 i think you need to write the XML to a file because it is ready made with slashes, then u need to read the xml then the slashes will be gone hopefully, or put it in a DB and then read it, people add slashes when they put stuff into databases and fuiles for storage so they know hich characters are not SQL ' is a SQL char so /' put into a db will come out as ', so put it in and take it out of a file or db, xml reader Classes objects usualy write a file and read it from there Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544862 Share on other sites More sharing options...
halfer2008 Posted May 19, 2008 Author Share Posted May 19, 2008 The xml is going to a file, and I'm trying to do this without a db. Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544867 Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 Its to do with the lis etc and nbsp when it goes to load in the xml. Is there a way I can make that stuff xml while also curing the problem i solved by use of the stripslashes? stripslashes is an amturish way of solving problems like these, u are stripping the slashes of XML simple methods to solve simple problems. the problem was additional slashes added by magic_quotes in the POST'ed content. to remove extra slashes added by magic_quotes, simply use stripslashes() and you'll get rid of the extra slashes added by magic_quotes while leaving the intended slashes in the content. Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-544987 Share on other sites More sharing options...
halfer2008 Posted May 20, 2008 Author Share Posted May 20, 2008 hi again @BluSkyIS. yes while the stripslahes() method worked to remove the extra content, I wasn't able to add things like links or ul or ol lists to the xml through the use of tinymce. any ideas on why that wouldn't work, I thought it may be to do with the stripslashes removing additional information i need for them to work. Quote Link to comment https://forums.phpfreaks.com/topic/106302-help-with-simple-xml-functionality/#findComment-545521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.