simplexml-load-string - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of simplexml-load-string.php
- <?php
- $string = "xmlmsg=%3CVersion%3E1.0%3C%2FVersion%3E%3COrderID%3E12191%3C%2FOrderID%3E%3CTransactionType%3EPurchase%3C%2FTransactionType%3E";
- $string = '<note>'.urldecode(str_replace('xmlmsg=','',$string)).'</note>';
- if ($xml = simplexml_load_string($string)) {
- echo "Order ID: " . $xml->OrderID;
- echo "\r\n";
- echo "Transaction Type: " . $xml->TransactionType;
- } else {
- echo "invalid xml format";
- }