xml - 使用纯 AS3 创建 Android manifest xml

标签 xml actionscript-3 namespaces android-manifest prefix

有人可以仅使用 Action Script 代码创建此 list xml 吗?我想制作一个创建 list 文件的应用程序,但我在前缀和命名空间上遇到了问题:

<manifest android:installLocation="auto">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

要生成的非常简单的示例 ActionScript 代码:
main = new XML(<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"/>);
main.appendChild(<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />)

原因:
TypeError: Error #1083: The prefix "android" for element "minSdkVersion" is not bound.

我不知道如何为 XML 文件设置前缀。

最佳答案

好的,所以我戳了一下它,这就是我的想法。

这有效:

var M:XML =

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />
</manifest>;

这不会:
var M:XML;

M = <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" />;
M.appendChild(<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />);

我不是 XML 专家,但我想是因为以下原因。我们可以将最后一段代码翻译为:
var U:XML = <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />;
var M:XML = <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" />;

M.appendChild(U);

我明确放了 U 之前 ,因为这里的顺序无关紧要,但这种方式不言自明。

如果你这样看,你会清楚地看到安卓前缀存在于 仅在 中从未存在过U . Flash Player 没有预知模块,也不知道您的意图 U 仅作为 的一部分男 .然后,作为一个单独的 XML 实例, U ,当您尝试创建它时,是无效的。

关于xml - 使用纯 AS3 创建 Android manifest xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50655117/

相关文章:

java - 使用 jdom 从 xml 文件中删除元素

android - 如何在此使用 Android 布局和自定义 GUI 设计

apache-flex - Flash Builder 4.5.1mobile 项目的嵌入元数据时间限制?

java - 使用 flex netConnection.call 方法检索列表

使用命名空间时,C++ 模板函数无法使用 g++ 进行编译

php - 使用 PHP 获取 XSD 内容

xml - 使用XmlSlurper解析xml时如何读取冒号属性名称(例如model:name)

actionscript-3 - adobe flex 日期格式

c# - 使用命名空间

c++ - 当函数模板专门用于不同的命名空间时,GCC 和 clang 不同意