我正在從AS2遷移到AS3,並且遇到了從XML獲取故障的節點。我能夠抓取(並跟蹤)AS3中的整個XML文件,但希望能夠使用firstChild將第一個標記存儲爲節點,並使用nextSibling遍歷標記。但是在AS3中,當我以前的AS2代碼實際上會抓取內容時,firstChild會一直空着。我究竟做錯了什麼? (我不能用自己的名字,因爲我重用多個XML文件的代碼塊調用標籤)AS3 XML節點遍歷
var eRoot = exampleXML.firstChild;
while (eRoot != null) {
//do stuff
eRoot= eRoot.nextSibling;
}
我測試的XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<content>
<version>cd</version>
<lessonlock>~-*~-*</lessonlock>
<expiryDate>**#*#**##**##**##*##********###*</expiryDate>
<isSpanish>true</isSpanish>
<server>http://www.exampleSite.com</server>
</content>
嘗試使用XMLDocument作爲as2樣式的xml http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/xml/XMLDocument.html – www0z0k 2012-04-20 21:10:22
謝謝,這就是我一直在尋找:) – woodlumhoodlum 2012-04-20 23:44:18