3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<div class="something-first"> <div class="something-child something-good another something-great"> <my:text value="huhu"> </div> </div>'; libxml_use_internal_errors(true); $domDoc = new DOMDocument(); /*$domDoc->formatOutput = false; $domDoc->resolveExternals = false; $domDoc->substituteEntities = false; $domDoc->strictErrorChecking = false; $domDoc->validateOnParse = false;*/ $domDoc->loadHTML($html/*, LIBXML_NOERROR | LIBXML_NOWARNING*/); $xpath = new DOMXPath($domDoc); $xpath->registerNamespace ('my', 'http://www.example.com/' ); // -----> This results in zero nodes cause namespace gets stripped by loadHTML() $nodes = $xpath->query('//my:text'); var_dump($nodes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjIHn
function name:  (null)
number of ops:  26
compiled vars:  !0 = $html, !1 = $domDoc, !2 = $xpath, !3 = $nodes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+class%3D%22something-first%22%3E%0A++++%3Cdiv+class%3D%22something-child+something-good+another+something-great%22%3E%0A++++++++%3Cmy%3Atext+value%3D%22huhu%22%3E%0A++++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
    9     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   11     4        NEW                                              $6      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   18     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   19    10        NEW                                              $10     'DOMXPath'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $10
   20    14        INIT_METHOD_CALL                                         !2, 'registerNamespace'
         15        SEND_VAL_EX                                              'my'
         16        SEND_VAL_EX                                              'http%3A%2F%2Fwww.example.com%2F'
         17        DO_FCALL                                      0          
   23    18        INIT_METHOD_CALL                                         !2, 'query'
         19        SEND_VAL_EX                                              '%2F%2Fmy%3Atext'
         20        DO_FCALL                                      0  $14     
         21        ASSIGN                                                   !3, $14
   24    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.2 ms | 1395 KiB | 17 Q