Advertisement
Guest User

inconsistent simplexml_load_string

a guest
Jul 21st, 2021
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. $xmlData = "<?xml version='1.0'?>
  3. <methodResponse>
  4. <params>
  5. <param>
  6. <value><array><data>
  7. <value><struct>
  8. <member>
  9. <name>description</name>
  10. <value><string></string></value>
  11. </member>
  12. </struct></value>
  13. </data></array></value>
  14. </param>
  15. </params>
  16. </methodResponse>";
  17.  
  18. $plainParsed = simplexml_load_string($xmlData);
  19. $NoNewLineParsed = simplexml_load_string(str_replace(array("\n", "\r"), '', $xmlData));
  20. $testArray = array($plainParsed, $NoNewLineParsed);
  21. foreach ($testArray as $test) {
  22.      var_dump(
  23.         $test->params->param->value->array->data->value->struct->member->value
  24.      );
  25. }
  26. //first pass (new lines not removed) returns array
  27. //second pass (new lines removed) returns element
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement