Skip to content

Attributes in default namespace behave oddly

Created by: IMSoP

There seems to be a bug (or misfeature?) in SimpleXML where attributes in the default namespace don't show if you call ->attributes($default_namespace_uri) rather than ->attributes('', true).

Because of simplexml_dump's attempts to display namespace information, this leads to data disappearing from view with innocuous XML like this:

<?php
include 'simplexml_dump.php';

$xml = <<<XML
<?xml version="1.0"?>
<Foo xmlns="http://example.com">
        <Bob InvisibleAttribute="You ain't seen me, right?">
                <MaskingChildElement />
        </Bob>
</Foo>
XML;

$sx_Foo = simplexml_load_string($xml);
simplexml_dump($sx_Foo->Bob);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information