如何使用NSXMLParser解析scxml文件

时间:2012-10-03 07:15:58

标签: iphone ios5 ios6 nsxmlparser

我有以下scxml文件

<?xml version = "1.0"?>
<scxml version="1.0" name="statemachine" initial="initialState" xmlns="http://www.w3.org/2005/07/scxml" binding="early" exmode="lax">

<state id="initialState">
    <transition target="state1" cond="TRUEPREDICATE" />
</state>
<state id="state1">
    <transition target="state2" cond="SELF.currentStateName == 'state1'" />
</state>
<state id="state2">
    <transition target="state1" cond="SELF.currentStateName == 'state2' && SELF.count <  5" />
    <transition target="finalState" cond="SELF.currentStateName == 'state2' && SELF.count >=  5" />
</state>
<state id="finalState"/>
</scxml>

我想使用NSXMLParser解析此文件。当我点击按钮时,我想要检查状态和目标 我想显示当前的状态值。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

整个文档将采用 Dictionary 格式。在此词典中,状态将是一个具有键ID且转换的词典是具有键target,cond的另一个词典。在-didStartElement中,您可以获得这些值。

猜猜,这对你有用!!