Simplexml get attributes with a namespace

You need to use the namespace when getting the attribute. The android namespace is defined as:

http://schemas.android.com/apk/res/android

So you need to pass that to the attributes() method, like this:

$xml = simplexml_load_string($xmlStr);

echo (string) $xml->application->activity->attributes('http://schemas.android.com/apk/res/android')->name;

Outputs

com.sunil.tweet.MainActivity

Codepad Demo