我想使用 simplexml 更改以命名空间为前缀的属性的值:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16">
这些方法不起作用:
$usesSDKTag['android:minSdkVersion'] = $minSdkVersion;
$usesSDKTag['minSdkVersion'] = $minSdkVersion;
我最终重新创建了节点并为其添加了带有命名空间前缀的属性:
if( isset($xmlManifest->{"uses-sdk"}) ) {
unset($xmlManifest->{"uses-sdk"});
}
$usesSDKTag = $xmlManifest->addChild('uses-sdk');
$usesSDKTag->addAttribute('android:minSdkVersion', $minSdkVersion, 'http://schemas.android.com/apk/res/android');
$usesSDKTag->addAttribute('android:targetSdkVersion', $minSdkVersion, 'http://schemas.android.com/apk/res/android');
$usesSDKTag->addAttribute('android:maxSdkVersion', $maxSdkVersion, 'http://schemas.android.com/apk/res/android');