我想使用simplexml:
更改以名称空间为前缀的属性的值<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16">
这些方法不起作用:
$usesSDKTag['android:minSdkVersion'] = $minSdkVersion;
$usesSDKTag['minSdkVersion'] = $minSdkVersion;
答案 0 :(得分:0)
我最终重新创建节点并添加带名称空间前缀的属性:
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');