diff --git a/src/simplexml_tree.php b/src/simplexml_tree.php index 094e612..518fe31 100644 --- a/src/simplexml_tree.php +++ b/src/simplexml_tree.php @@ -158,13 +158,15 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string // If things are in the current namespace, display them a bit differently $is_current_namespace = ( $ns_uri == reset($item_ns) ); - + + $ns_uri_quoted = (strlen($ns_uri) == 0 ? 'null' : "'$ns_uri'"); + if ( count($attributes) > 0 ) { if ( ! $is_current_namespace ) { $dump .= str_repeat($indent, $depth) - . "->attributes('$ns_alias', true)" . PHP_EOL; + . "->attributes($ns_uri_quoted)" . PHP_EOL; } foreach ( $attributes as $sx_attribute ) @@ -219,7 +221,7 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string else { $dump .= str_repeat($indent, $depth) - . "->children('$ns_alias', true)" . PHP_EOL; + . "->children($ns_uri_quoted)" . PHP_EOL; $display_depth = $depth + 1; } diff --git a/tests/tree-output/basic-default-ns b/tests/tree-output/basic-default-ns index dc26004..67aa4c3 100644 --- a/tests/tree-output/basic-default-ns +++ b/tests/tree-output/basic-default-ns @@ -1,6 +1,6 @@ SimpleXML object (1 item) [0] // - ->children('', true) + ->children('https://github.com/IMSoP/simplexml_debug') ->movie[0] ->title[0] ->characters[0] diff --git a/tests/tree-output/basic-ns b/tests/tree-output/basic-ns index 46179c3..88518ae 100644 --- a/tests/tree-output/basic-ns +++ b/tests/tree-output/basic-ns @@ -1,6 +1,6 @@ SimpleXML object (1 item) [0] // - ->children('test', true) + ->children('https://github.com/IMSoP/simplexml_debug') ->movie[0] ->title[0] ->characters[0] @@ -14,8 +14,8 @@ SimpleXML object (1 item) ->great-lines[0] ->line[0] ->rating[0] - ->attributes('', true) + ->attributes(null) ->type ->rating[1] - ->attributes('', true) + ->attributes(null) ->type diff --git a/tests/tree-output/soap b/tests/tree-output/soap index d212f00..7819028 100644 --- a/tests/tree-output/soap +++ b/tests/tree-output/soap @@ -1,15 +1,15 @@ SimpleXML object (1 item) [0] // - ->children('soap', true) + ->children('http://schemas.xmlsoap.org/soap/envelope/') ->Header[0] - ->children('s', true) + ->children('http://example.org/security') ->credentials[0] - ->children('', true) + ->children(null) ->username[0] ->password[0] ->Body[0] - ->children('tns', true) + ->children('http://example.org/some-soap-service') ->DoSomething[0] - ->children('', true) + ->children(null) ->from[0] ->to[0]