I’m using DOMDocument to generate a XML and this XML has to have an image-Tag.
Somehow, when I do (simplified)
$response = new DOMDocument();
$actions = $response->createElement('actions');
$response->appendChild($actions);
$imageElement = $response->createElement('image');
$actions->appendChild($imageElement);
$anotherNode = $response->createElement('nodexy');
$imageElement->appendChild($anotherNode);
it results in
<actions>
<img>
<node></node>
</actions>
If I change ‘image’ to ‘images’ or even ‘img’ it works. It does work as well when I switch from PHP 5.3.10 to 5.3.8.
Is this a bug or a feature? My guess is that DOMDocuments assumes that I want to build an HTML img Element … Can I prevent this somehow?
Weird thing on top: I’m not able to reproduce the error in another script on the same server. But I do not catch the pattern …
Here’s a complete pastebin of the class, that’s causing the error: http://pastebin.com/KqidsssM
That costed me two hours.
DOMDocument renders the XML correctly. The XML is returned by an ajax call and somehow the browser/javascript changes it to img before displaying it …