作者l314 (紅虫)
看板Flash
標題Re: [問題] xmlns:aaa="Main"
時間Fri Aug 27 16:48:18 2010
謝謝邦邦大大..
加了<td/>之後的確就不會再跑出namespace了..
另外我試著把下面幾行
catalog.body.shopNS::table.table.tr.td = "Item";
catalog.body.shopNS::table.table.tr.td += <td/>;
catalog.body.shopNS::table.table.tr.td[1] = "Price";
catalog.body.shopNS::table.table.tr.td += <td/>;
catalog.body.shopNS::table.table.tr.td[2] = "Price2";
改成
catalog.body.shopNS::table.table.tr.appendChild(<td></td>);
catalog.body.shopNS::table.table.tr.td = "Item";
catalog.body.shopNS::table.table.tr.appendChild(<td></td>);
catalog.body.shopNS::table.table.tr.td[1] = "Price";
catalog.body.shopNS::table.table.tr.appendChild(<td></td>);
catalog.body.shopNS::table.table.tr.td[2] = "Price2";
結果也不會出現namespace...
所以Essential ActionScript 3.0 上 原本的example codes 在你的flex builder上執行也是有問題的囉?
請問邦邦大大知道原因嗎?
謝謝.
※ 引述《ben0209 (邦邦)》之銘言:
: 使用 FB 3 搭配 SDK 3
: package {
: import flash.display.Sprite;
: public class TestXmlNameSpace extends Sprite
: {
: public function TestXmlNameSpace()
: {
: var htmlNS:Namespace = new Namespace("html",
: "http://www.w3.org/1999/xhtml");
: var shopNS:Namespace = new Namespace("shop",
: "http://example.com/furniture");
: default xml namespace = htmlNS;
: var catalog:XML = <html/>;
: catalog.addNamespace(shopNS);
: catalog.head.title = "Catalog";
: catalog.body.shopNS::table = "";
: catalog.body.shopNS::table.@shopNS::id = "4875";
: catalog.body.shopNS::table.table = "";
: catalog.body.shopNS::table.table.@border = "1";
: catalog.body.shopNS::table.table.tr.td = "Item";
: catalog.body.shopNS::table.table.tr.td += <td/>;
: catalog.body.shopNS::table.table.tr.td[1] = "Price";
: catalog.body.shopNS::table.table.tr.td += <td/>;
: catalog.body.shopNS::table.table.tr.td[2] = "Price2";
: trace(catalog.toXMLString());
: }
: }
: }
: 輸出結果:
: <html xmlns:shop="http://example.com/furniture"
: xmlns="http://www.w3.org/1999/xhtml">
: <head>
: <title>Catalog</title>
: </head>
: <body>
: <shop:table shop:id="4875">
: <table border="1">
: <tr>
: <td>Item</td>
: <td>Price</td>
: <td>Price2</td>
: </tr>
: </table>
: </shop:table>
: </body>
: </html>
: [SWF] D:\works_test\TestXmlNameSpace\bin-debug\TestXmlNameSpace.swf - 1,878
: bytes after decompression
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.251.117.162
→ ben0209:我在看 EAS3 時,沒有全部實作過,不過對於這個問題, 08/30 11:03
→ ben0209:直接使用 E4X 的語法,你要小心處理 XML 與 XMLList`, 08/30 11:05
→ ben0209:增加 <td> 的用意,就是讓他成為 XMLList,這樣寫 [1] 才 08/30 11:06
→ ben0209:有意義 08/30 11:06
→ l314:感謝~~ 08/30 11:15