主应用代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center"
verticalAlign="middle"
creationComplete="initApp()">
<mx:Script>
<!--[CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
private function initApp():void
{
//Initialize XML load service.
sevBaseTable.send();
}
// Load BaseTable.xml
private function loadBaseTableHandler(event:ResultEvent):void
{
connManager.openConnection(dbConnection);
createDbObj.createTableArray=event.result.tables.table;
createDbObj.createDatabaseObjects(dbConnection);
connManager.closeConnection(dbConnection);
Debug.log("Load BaseTable.xml complete!");
}
]]-->
</mx:Script>
<mx:HTTPService id="sevBaseTable"
url="data/BaseTable.xml"
result="loadBaseTableHandler(event)"/>
</mx:Application>
XML文件:
BaseTable.xml
<?xml version="1.0"?>
<tables>
<table>
<name>TRP_USERS</name>
<statement>CREATE TABLE IF NOT EXISTS TRP_USERS (USER_ID INTEGER PRIMARY KEY AUTOINCREMENT,USER_NAME TEXT,PASSWORD TEXT,CREATION_DATE DATE)</statement>
</table>
<tables>
运行时会报错:类似空方法的错误
调试结果:
在BaseTable.xml中
添加一个<table></table>节点,则不会再报错。
猜想:可能是当xml文件解析结果只有一个节点时无法识别ArrayCollection。