The manual doesn't really explain what the $ns argument (and the accompanying $is_prefix) are for.
What they do is similar to the ->children() method: they set the context of the returned object to that namespace, so that access via ->elementName and ['attributeName'] refer to elements and attributes in that namespace.
In particular, they do *not* change the namespaces which exist on the document.
See this example:
<?php
// This XML contains two elements called <child>
// One is in the namespace http://example.com, with local prefix 'ws'
// The other has no namespace (no prefix, and no default namespace declared)
$xml = '<ws:example xmlns:ws="http://example.com"><child>Not in namespace</child><ws:child>In example namespace</ws:child></ws:example>';
$sx0 = new SimpleXMLElement($xml, 0, false);
$sx1 = new SimpleXMLElement($xml, 0, false, 'http://example.com');
$sx2 = new SimpleXMLElement($xml, 0, false, 'ws', true);
echo "
Without: {$sx0->child}
By namespace: {$sx1->child}
By prefix: {$sx2->child}
";
?>
Output:
Without: Not in namespace
By namespace: In example namespace
By prefix: In example namespace