我使用本地xml文件。當我在Web瀏覽器中刪除一個項目時,它將被刪除,但xml文件不會更改。這是爲什麼附加? 這是我的xml文件;從DataGrid中刪除,添加並保存項目在xml中
<?xml version="1.0" encoding="utf-8" ?>
<products>
<product>
<productId>1</productId>
<categoryId>1</categoryId>
<name>Azalea</name>
<nickname>California Snow</nickname>
<instructions>Large double.</instructions>
<catalogNumber>S1</catalogNumber>
<price>15.99</price>
<photo>california_snow.jpg</photo>
</product>
<product>
<productId>2</productId>
<categoryId>1</categoryId>
<name>Tibouchina Semidecandra</name>
<instructions>Beautiful large royal.</instructions>
<catalogNumber>S2</catalogNumber>
<price>33.99</price>
<photo>princess_flower.jpg</photo>
</product>
...
我在下面寫下這些代碼。同時如何添加和更改它? 已經非常感謝你
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
skinClass="skins.HPAppSkin">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
productCollection.removeItemAt(productGrid.selectedIndex);
}
]]>
</fx:Script>
<fx:Declarations>
<fx:Model id="productModel" source="data/products.xml"/>
<s:ArrayList id="productCollection"
source="{productModel.product}"/>
</fx:Declarations>
<mx:DataGrid id="productGrid" dataProvider="{productCollection}"/>
<s:Button label="Remove Item" click="button1_clickHandler(event)"
enabled="{productGrid.selectedIndex != -1}"/>
</s:Application>