我的XML看起来是这样的:如何将一个孩子追加到包含多个项目的列表中。
<Database>
<Year name="2015" spent="" saved="">
<Month name="" spent="" saved="">
<Day date="" name="" spent="" saved="">
<Entry title="" category="" currency="" cost="" time=""/>
</Day>
</Month>
</Year>
<Year name="2016" spent="" saved="150">
<Month name="" spent="" saved="">
<Day date="" name="" spent="" saved="">
<Entry title="" category="" currency="" cost="" time=""/>
</Day>
</Month>
当我使用
myXML.Year.appendChild(<Month name="2016" spent="150" saved="152"></Month>);
我得到以下错误:
TypeError: Error #1086: The appendChild method only works on lists containing one item.
at XMLList/http://adobe.com/AS3/2006/builtin::appendChild()
任何想法?
这是我正在做的事情:我正在开发一个android应用程序,记录并跟踪日常开支。因此,当用户为2015年添加新条目时,我会检查该年是否已经存在,如果我想在年内进入并查看月份是否存在,以及是否存在,那么我检查是否存在当前日子已经存在。如果是这样,我在日期列表中添加新条目,如果没有,我会在日期列表中创建一个新节点。几年和几个月也是如此。我很难弄清楚这一点。任何帮助是极大的赞赏。
太棒了,非常感谢! –