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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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