0
嵌入XML我試圖嵌入一些XML到我的應用程序,但我得到以下錯誤不能在FlashDevelop中
Fault] exception, information=TypeError: Error #1090: XML parser failure: element is malformed.
這裏是我的代碼。
package
{
import com.objects.EngineApi;
import com.objects.Rectangles;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
/**
* ...
* @author Anthony Gordon
*/
public class Main extends Sprite
{
[Embed(source = "com/files/level1.xml", mimeType = "application/octet-stream")]
private var theClass:Class;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
var xmlObj:Object = new theClass();
trace(xmlObj);
var xml:XML = new XML(xmlObj) as XML;
}
}
}
XML代碼
< STAGE>
< OBJECTS>
< BLOCK X="2" Y="23" WIDTH="36" HEIGHT="4" />
< SPAWN X="6" Y="22" />
< BLOCK X="12" Y="21" WIDTH="4" HEIGHT="2" />
< TUTORIAL X="18" Y="16" TEXT="..." />
< TUTORIAL X="28" Y="22" TEXT="..." />
< BLOCK X="36" Y="2" WIDTH="2" HEIGHT="16" />
< JUMPTHRU X="32" Y="9" WIDTH="4" />
< BLOCK X="27" Y="9" WIDTH="5" HEIGHT="2" />
< COIN X="28" Y="7" />
< COIN X="30" Y="7" />
< COIN X="32" Y="7" />
< COIN X="34" Y="7" />
< BLOCK X="17" Y="8" WIDTH="5" HEIGHT="2" />
< BLOCK X="2" Y="9" WIDTH="10" HEIGHT="2" />
< CHEST X="19" Y="7" COINS="5" />
< DOOR X="5" Y="8" />
< BLOCK X="37" Y="20" WIDTH="2" HEIGHT="3" />
< BLOCK X="1" Y="5" WIDTH="3" HEIGHT="4" />
< BIRD_GOLD X="2" Y="4" COINS="3" TIME="5" />
</ OBJECTS>
</ STAGE>
什麼是您的XML是什麼樣子? – 2010-02-09 05:12:08
'XML解析器失敗'表示錯誤出現在您的xml文件中。 嘗試在Firefox中打開它,看看錯誤是什麼。 – Daniel 2010-02-09 05:18:01
我更新了上面的代碼。我需要一個prolog嗎? – numerical25 2010-02-09 06:59:04