Fix #5: Be opinionated and show namespace URIs rather than prefixes

This commit is contained in:
Rowan Collins 2017-11-09 22:04:51 +00:00
parent 6ac7c40043
commit 16622d96f3
4 changed files with 14 additions and 12 deletions

View file

@ -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 // If things are in the current namespace, display them a bit differently
$is_current_namespace = ( $ns_uri == reset($item_ns) ); $is_current_namespace = ( $ns_uri == reset($item_ns) );
$ns_uri_quoted = (strlen($ns_uri) == 0 ? 'null' : "'$ns_uri'");
if ( count($attributes) > 0 ) if ( count($attributes) > 0 )
{ {
if ( ! $is_current_namespace ) if ( ! $is_current_namespace )
{ {
$dump .= str_repeat($indent, $depth) $dump .= str_repeat($indent, $depth)
. "->attributes('$ns_alias', true)" . PHP_EOL; . "->attributes($ns_uri_quoted)" . PHP_EOL;
} }
foreach ( $attributes as $sx_attribute ) foreach ( $attributes as $sx_attribute )
@ -219,7 +221,7 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string
else else
{ {
$dump .= str_repeat($indent, $depth) $dump .= str_repeat($indent, $depth)
. "->children('$ns_alias', true)" . PHP_EOL; . "->children($ns_uri_quoted)" . PHP_EOL;
$display_depth = $depth + 1; $display_depth = $depth + 1;
} }

View file

@ -1,6 +1,6 @@
SimpleXML object (1 item) SimpleXML object (1 item)
[0] // <movies> [0] // <movies>
->children('', true) ->children('https://github.com/IMSoP/simplexml_debug')
->movie[0] ->movie[0]
->title[0] ->title[0]
->characters[0] ->characters[0]

View file

@ -1,6 +1,6 @@
SimpleXML object (1 item) SimpleXML object (1 item)
[0] // <movies> [0] // <movies>
->children('test', true) ->children('https://github.com/IMSoP/simplexml_debug')
->movie[0] ->movie[0]
->title[0] ->title[0]
->characters[0] ->characters[0]
@ -14,8 +14,8 @@ SimpleXML object (1 item)
->great-lines[0] ->great-lines[0]
->line[0] ->line[0]
->rating[0] ->rating[0]
->attributes('', true) ->attributes(null)
->type ->type
->rating[1] ->rating[1]
->attributes('', true) ->attributes(null)
->type ->type

View file

@ -1,15 +1,15 @@
SimpleXML object (1 item) SimpleXML object (1 item)
[0] // <soap:Envelope> [0] // <soap:Envelope>
->children('soap', true) ->children('http://schemas.xmlsoap.org/soap/envelope/')
->Header[0] ->Header[0]
->children('s', true) ->children('http://example.org/security')
->credentials[0] ->credentials[0]
->children('', true) ->children(null)
->username[0] ->username[0]
->password[0] ->password[0]
->Body[0] ->Body[0]
->children('tns', true) ->children('http://example.org/some-soap-service')
->DoSomething[0] ->DoSomething[0]
->children('', true) ->children(null)
->from[0] ->from[0]
->to[0] ->to[0]