0

我想使用 simplexml 更改以命名空间为前缀的属性的值:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16">

这些方法不起作用:

$usesSDKTag['android:minSdkVersion'] = $minSdkVersion;
$usesSDKTag['minSdkVersion'] = $minSdkVersion;
4

1 回答 1

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');
于 2012-11-01T15:14:41.987 回答