Asked  2 Years ago    Answers:  5   Viewed   78 times

I have an XML Document which has attributes with a namespace. The XML looks like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
android:versionName="1.0" >

    android:targetSdkVersion="16" />

    android:theme="@style/AppTheme" >
        android:label="@string/app_name" >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

How can I extract the android:name attribute from the activity tag?



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

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

$xml = simplexml_load_string($xmlStr);

echo (string) $xml->application->activity->attributes('')->name;



Codepad Demo

Saturday, September 17, 2022

The site is blocking requests from PHP.

First run

ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0');

(or some other valid user agent) and it will work.

Tuesday, September 13, 2022

With some quick searching on how to retrieve XML via cURL this is what I did to retrieve and parse the XML.

The big reason as I mentioned above in a comment is that you can't pass URLs directly into the simple_xml_load_string function with ampersands(&) in them. It's a character in the XML format that represents entities.


function get_xml_from_url($url){
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080311 Firefox/');

    $xmlstr = curl_exec($ch);

    return $xmlstr;

$url = '';
$contents = get_xml_from_url($url);

$xml = simplexml_load_string($contents);

echo '<pre>';
echo '</pre>';
Saturday, September 3, 2022

I found it's not enough for the app and account to be added as owners. I would go into your storage account > IAM > Add role assignment, and add the special permissions for this type of request:

  • Storage Blob Data Contributor
  • Storage Queue Data Contributor
Saturday, September 3, 2022

It depends on how you want to your partners usig the account login-in. If you expected that the partners login-in using the consumer account or local account in the Azure AD B2C you own, the answer is yes.

The Azure AD B2C supports the Access Tokens from March 23, 2017(refer here). And it supports many types of clients, including web apps, desktop and mobile apps, single page apps, server-side daemons, and other web APIs.

It is same to develop an web API server for one native app or multiples apps, you only need to register the multiple apps in your B2C tenant. More detail about acquring the access token for the Azure AD B2C, you can refer the link below:

Azure Active Directory B2C: OAuth 2.0 authorization code flow

Sunday, August 28, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages