3
與insertChildBefore和insertChildAfter麻煩我有一個XML文檔:有在AS3
var xml:XML = new XML(<rootNode>
<head>
<meta name="template" content="Default" />
</head>
<mainSection>
<itemList>
<item>
<video src={this.videoURL} />
<img src={this.src}></img>
</item>
</itemList>
</mainSection>
</rootNode>);
我想怎麼辦,是一定條件時我在itemList中的開頭插入另一個。
var newNode:XMLList = new XMLList("<item><video src=\"" + _videoSource + "\"></video></item>");
我能夠生成和跟蹤newNode就好了,但每當我嘗試使用insertChildBefore
添加它,它總是返回undefined。
var contentNode:XML = new XML(xml.mainSection.itemList.item);
xml.insertChildBefore(contentNode ,newNode)
contentNode
總是跟蹤正常,但試圖insertChildBefore
或insertChildAfter
時總是失敗。奇怪的是,如果我使contentNode
不那麼具體(如xml.mainSection
),那麼它按預期工作。
感謝您的幫助,這讓我瘋狂!
的感謝!我認爲我們在這裏正確的軌道,但parentNode是空的。 – nerdabilly 2008-10-09 20:38:04