作者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
1F:→ ben0209:我在看 EAS3 时,没有全部实作过,不过对於这个问题, 08/30 11:03
2F:→ ben0209:直接使用 E4X 的语法,你要小心处理 XML 与 XMLList`, 08/30 11:05
3F:→ ben0209:增加 <td> 的用意,就是让他成为 XMLList,这样写 [1] 才 08/30 11:06
4F:→ ben0209:有意义 08/30 11:06
5F:→ l314:感谢~~ 08/30 11:15