jamesm6162 Posted March 10, 2009 Share Posted March 10, 2009 I have a form where users enter a paragraph, which I then save in an XML file, using PHP's DOMDocument. However, as soon as someone copies a special character (i.e. “ - character, not the normal double quote, but ‘ numerical entity.) Then the value is not saved to the XML file at all, but leaves an empty element. That is when I do not specify any Character encoding in my XML document. Whats more, this problem only occurs on the remote server, and not my localhost. Does anybody know how I can fix it? Quote Link to comment https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/ Share on other sites More sharing options...
btherl Posted March 10, 2009 Share Posted March 10, 2009 Can you post your code? If you can find out as much configuration and version information about both your local host and the remote server, that will help too. Also the operating systems being used. Quote Link to comment https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/#findComment-781102 Share on other sites More sharing options...
jamesm6162 Posted March 10, 2009 Author Share Posted March 10, 2009 Okay here is my PHP code $doc = new DOMDocument(); $doc->load($file); ... //The following nodes are children somewhere in the document. ... $titlenode->nodeValue = $_POST['title']; $descnode->nodeValue = $_POST['description']; //contains the special characters, but isn't saved. $datenode->nodeValue = $_POST['date']; $doc->save($file); It's really basic code. Local Machine is a Win XP Remote is Linux ais-web01 2.4.25-bf2.4 Both running Apache 2.0 and PHP 5.2.6 I'm not sure exactly what information you need though... Quote Link to comment https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/#findComment-781120 Share on other sites More sharing options...
btherl Posted March 10, 2009 Share Posted March 10, 2009 Hmm.. if you are not specifying a character encoding, perhaps you need to? If you specify the same on both servers it ought to work in the same way. Quote Link to comment https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/#findComment-781711 Share on other sites More sharing options...
.josh Posted March 11, 2009 Share Posted March 11, 2009 or you could possibly str_replace it with the quote you want. or you could possibly look into using utf8_encode or similar (follow the link and similar methods in the manual). Quote Link to comment https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/#findComment-781798 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.