IMSoP / simplexml_debug

Tools for debugging your code when working with PHP's SimpleXML functions.
MIT License
52 stars 16 forks source link

Element in default namespace displayed wrong if attribute has a namespace #11

Closed IMSoP closed 7 years ago

IMSoP commented 7 years ago

While constructing tests for #3, I found a different oddity: currently, I'm relying on ->getNamespaces(false) returning the namespace of the current element, but that's not actually what it does. Instead, it lists all namespaces used by the current element, including its attributes.

Consider the following:

<?xml version="1.0" standalone="yes"?>
<notinnamespace xmlns:test="http://example.com" test:isinnamespace="true" />

Here, the prefix test is used in the element (by the attribute) but isn't the namespace to which the element belongs. Since there is no default namespace defined, there's no '' key in the getNamespaces output, so the output is [ 'test' => 'http://example.com' ], leading to broken dump output.