3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0"?> <xdm:Device xmlns:xdm="http://www.hp.com/schemas/imaging/con/xdm/1.1/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/" xmlns:bsi="http://www.hp.com/schemas/imaging/con/bsi/2003/08/21" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:count="http://www.hp.com/schemas/imaging/con/counter/2006/01/13" xmlns:media="http://www.hp.com/schemas/imaging/con/media/2006/01/13/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tt="http://www.hp.com/schemas/imaging/con/capabilities/1.1/" xmlns:pwg="http://www.hp.com/schemas/imaging/con/pwg/sm/1.0/"> <xdm:Information> <xdm:Component id="system" componentType="system"> <dd:MakeAndModel>Samsung LaserJet ML220</dd:MakeAndModel> <dd:Description>Blackand while printer</dd:Description> <dd:ProductNumber>XB3zzz</dd:ProductNumber> <dd:Manufacturer> <dd:Name>Samsung</dd:Name> </dd:Manufacturer> </xdm:Component> </xdm:Information> </xdm:Device>'; // Defining my own ways of referring to the namespaces, regardless of prefix used define('XMLNS_HP_XDM_1_1', 'http://www.hp.com/schemas/imaging/con/xdm/1.1/'); define('XMLNS_HP_DICT_1_0', 'http://www.hp.com/schemas/imaging/con/dictionaries/1.0/'); // Load the XML in the normal way $sx = simplexml_load_string($xml); // Switch to the first namespace, and look at the first Component $component = $sx->children(XMLNS_HP_XDM_1_1)->Information->Component; $component_id = (string)$component->attributes(null)->id; // Switch to the second namespace to find the MakeAndModel $make_and_model = (string)$component->children(XMLNS_HP_DICT_1_0)->MakeAndModel; echo "$component_id : $make_and_model";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXXv8
function name:  (null)
number of ops:  38
compiled vars:  !0 = $xml, !1 = $sx, !2 = $component, !3 = $component_id, !4 = $make_and_model
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Cxdm%3ADevice+xmlns%3Axdm%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fxdm%2F1.1%2F%22+%0A+++++++++++xmlns%3Add%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fdictionaries%2F1.0%2F%22+%0A+++++++++++xmlns%3Absi%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fbsi%2F2003%2F08%2F21%22+%0A+++++++++++xmlns%3Awsdl%3D%22http%3A%2F%2Fschemas.xmlsoap.org%2Fwsdl%2F%22+%0A+++++++++++xmlns%3Acount%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fcounter%2F2006%2F01%2F13%22+%0A+++++++++++xmlns%3Amedia%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fmedia%2F2006%2F01%2F13%2F%22+%0A+++++++++++xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+%0A+++++++++++xmlns%3Att%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fcapabilities%2F1.1%2F%22+%0A+++++++++++xmlns%3Apwg%3D%22http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fpwg%2Fsm%2F1.0%2F%22%3E%0A++++%3Cxdm%3AInformation%3E++++++++%0A++++++++%3Cxdm%3AComponent+id%3D%22system%22+componentType%3D%22system%22%3E%0A++++++++++++%3Cdd%3AMakeAndModel%3ESamsung+LaserJet+ML220%3C%2Fdd%3AMakeAndModel%3E%0A++++++++++++%3Cdd%3ADescription%3EBlackand+while+printer%3C%2Fdd%3ADescription%3E%0A++++++++++++%3Cdd%3AProductNumber%3EXB3zzz%3C%2Fdd%3AProductNumber%3E%0A++++++++++++%3Cdd%3AManufacturer%3E%0A++++++++++++++++%3Cdd%3AName%3ESamsung%3C%2Fdd%3AName%3E%0A++++++++++++%3C%2Fdd%3AManufacturer%3E%0A++++++++%3C%2Fxdm%3AComponent%3E%0A++++%3C%2Fxdm%3AInformation%3E++++%0A%3C%2Fxdm%3ADevice%3E'
   26     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'XMLNS_HP_XDM_1_1'
          3        SEND_VAL                                                 'http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fxdm%2F1.1%2F'
          4        DO_ICALL                                                 
   27     5        INIT_FCALL                                               'define'
          6        SEND_VAL                                                 'XMLNS_HP_DICT_1_0'
          7        SEND_VAL                                                 'http%3A%2F%2Fwww.hp.com%2Fschemas%2Fimaging%2Fcon%2Fdictionaries%2F1.0%2F'
          8        DO_ICALL                                                 
   30     9        INIT_FCALL                                               'simplexml_load_string'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !1, $8
   33    13        INIT_METHOD_CALL                                         !1, 'children'
         14        FETCH_CONSTANT                                   ~10     'XMLNS_HP_XDM_1_1'
         15        SEND_VAL_EX                                              ~10
         16        DO_FCALL                                      0  $11     
         17        FETCH_OBJ_R                                      ~12     $11, 'Information'
         18        FETCH_OBJ_R                                      ~13     ~12, 'Component'
         19        ASSIGN                                                   !2, ~13
   34    20        INIT_METHOD_CALL                                         !2, 'attributes'
         21        SEND_VAL_EX                                              null
         22        DO_FCALL                                      0  $15     
         23        FETCH_OBJ_R                                      ~16     $15, 'id'
         24        CAST                                          6  ~17     ~16
         25        ASSIGN                                                   !3, ~17
   37    26        INIT_METHOD_CALL                                         !2, 'children'
         27        FETCH_CONSTANT                                   ~19     'XMLNS_HP_DICT_1_0'
         28        SEND_VAL_EX                                              ~19
         29        DO_FCALL                                      0  $20     
         30        FETCH_OBJ_R                                      ~21     $20, 'MakeAndModel'
         31        CAST                                          6  ~22     ~21
         32        ASSIGN                                                   !4, ~22
   39    33        ROPE_INIT                                     3  ~25     !3
         34        ROPE_ADD                                      1  ~25     ~25, '+%3A+'
         35        ROPE_END                                      2  ~24     ~25, !4
         36        ECHO                                                     ~24
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.11 ms | 1016 KiB | 15 Q