xml文件
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="PACKAGE" android:versionName="VERSIONNAME"> <application android:icon="ICON" android:label="LABEL" android:name="NAME"> </application> <uses-sdk android:minSdkVersion="1" /> <uses-sdk android:maxSdkVersion="2" /> <uses-permission android:name="android.permission.FOO"></uses-permission> <uses-permission android:name="android.permission.BAR"></uses-permission> </manifest>
php代码
<?php $xml = new SimpleXMLElement(file_get_contents('AndroidManifest.xml')); $nodes = $xml->xpath('/manifest'); var_dump((string)$nodes[0]->attributes()->package); var_dump((string)$nodes[0]->attributes('android', true)->versionName); $nodes = $xml->xpath('/manifest/application'); var_dump((string)$nodes[0]->attributes('android', true)->icon); var_dump((string)$nodes[0]->attributes('android', true)->label); var_dump((string)$nodes[0]->attributes('android', true)->name); $nodes = $xml->xpath('/manifest/uses-sdk'); foreach ($nodes as $node) { foreach ($node->attributes('android', true) as $attribute => $value) { var_dump($attribute, (string)$value); } } $nodes = $xml->xpath('/manifest/uses-permission'); foreach ($nodes as $node) { foreach ($node->attributes('android', true) as $attribute => $value) { var_dump($attribute, (string)$value); } } ?>