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.



Your result can be seen below.

Result of php executing





Full code of simplexml-load-string.php

  1. <?php
  2. $string = "xmlmsg=%3CVersion%3E1.0%3C%2FVersion%3E%3COrderID%3E12191%3C%2FOrderID%3E%3CTransactionType%3EPurchase%3C%2FTransactionType%3E";
  3. $string = '<note>'.urldecode(str_replace('xmlmsg=','',$string)).'</note>';
  4.  
  5. if ($xml = simplexml_load_string($string)) {
  6. echo "Order ID: " . $xml->OrderID;
  7. echo "\r\n";
  8. echo "Transaction Type: " . $xml->TransactionType;
  9. } else {
  10.     echo "invalid xml format";
  11. }
File Description
  • simplexml-load-string
  • PHP Code
  • 03 May-2018
  • 407 Bytes
You can Share it: