ActionScript 3 解析XML文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 解析XML文件相关的知识,希望对你有一定的参考价值。

Example XML code:

<question id = "a3" incorrectFeedBackID = "18190" correctFeedbackID = "18189">
	<answer id = "18183" isCorrect = "false"></answer>
	<answer id = "18184" isCorrect = "true"></answer>
	<answer id = "18185" isCorrect = "true"></answer>
	<answer id = "18186" isCorrect = "false"></answer>
	<answer id = "18187" isCorrect = "true"></answer>
	<answer id = "18188" isCorrect = "true"></answer>
</question>

<question id = "a5" incorrectFeedBackID = "18199" correctFeedbackID = "18198">
	<answer id = "18192" isCorrect = "false"></answer>
	<answer id = "18193" isCorrect = "true"></answer>
	<answer id = "18194" isCorrect = "true"></answer>
	<answer id = "18195" isCorrect = "true"></answer>
	<answer id = "18196" isCorrect = "false"></answer>
	<answer id = "18197" isCorrect = "true"></answer>
</question>
___________________________________________________________________
To get the incorrectFeedBackID for a5:

trace("incorrectFeedBackID:", xml["question"][1].@incorrectFeedBackID);
or
trace(xml.question.(@id == "a5").@incorrectFeedBackID);
___________________________________________________________________
To get the isCorrect value for 18193 in question a5:

trace("isCorrectValue:", xml["question"][1]["answer"][1].@isCorrect);
or
trace(xml.question.(@id == "a5").answer.(@id == "18193").@isCorrect);

以上是关于ActionScript 3 解析XML文件的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 使用换行符解析XML!

ActionScript 3 xml解析

使用 Actionscript 3 连接到数据库 [关闭]

ActionScript XML解析器

如何在 Actionscript 3 中将数据写入 XML 文件

ActionScript 3 加载多个XML文件