Jump to content

Save Special characters in XML


jamesm6162

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/148758-save-special-characters-in-xml/
Share on other sites

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.