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('//text'); var_dump($nodes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JtM7n
function name:  (null)
number of ops:  36
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
   12     7        ASSIGN_OBJ                                               !1, 'formatOutput'
          8        OP_DATA                                                  <false>
   13     9        ASSIGN_OBJ                                               !1, 'resolveExternals'
         10        OP_DATA                                                  <false>
   14    11        ASSIGN_OBJ                                               !1, 'substituteEntities'
         12        OP_DATA                                                  <false>
   15    13        ASSIGN_OBJ                                               !1, 'strictErrorChecking'
         14        OP_DATA                                                  <false>
   16    15        ASSIGN_OBJ                                               !1, 'validateOnParse'
         16        OP_DATA                                                  <false>
   18    17        INIT_METHOD_CALL                                         !1, 'loadHTML'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
   19    20        NEW                                              $15     'DOMXPath'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $15
   20    24        INIT_METHOD_CALL                                         !2, 'registerNamespace'
         25        SEND_VAL_EX                                              'my'
         26        SEND_VAL_EX                                              'http%3A%2F%2Fwww.example.com%2F'
         27        DO_FCALL                                      0          
   23    28        INIT_METHOD_CALL                                         !2, 'query'
         29        SEND_VAL_EX                                              '%2F%2Ftext'
         30        DO_FCALL                                      0  $19     
         31        ASSIGN                                                   !3, $19
   24    32        INIT_FCALL                                               'var_dump'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.02 ms | 1396 KiB | 17 Q