This is the next question to this question:
How to process XML with PHP that was sent to the server as text / xml?
JavaScript / jQuery:
var xmlDoc = jQuery.createXMLDocument( "<items></items>" ); jQuery( "items", xmlDoc ).append( jQuery( "<item>My item!</item>" ) ); jQuery.ajax({ url: "test.php", type: "POST", processData: false, contentType: "text/xml", data: xmlDoc, success: function( data ) { alert( data ); } });
PHP:
$xml_text = file_get_contents("php://input"); $xml = simplexml_load_string($xml_text); echo $xml->ITEM;
For this to work, I have to use $ xml-> ITEM. If I use the $ xml-> element, it will not work. I was wondering why, when a node element is added, it is lowercase, but when I extract it, it should now be uppercase? I would like this to be lowercase in my PHP. Thanks.
user4903
source share