需要使用NSXMLParser在同一段XML上重复解析(循环)

时间:2016-07-06 21:13:25

标签: objective-c xml ios9 nsxmlparser

我有一串XML,我想用它来描述表格布局。有点像模板。我使用NSXMLParser来解析它。

<section title="section a">
    <row label="name" property="fullname" />
    <row label="gender" property="gender" />
</section>
<section title="section b">
    <row label="pet" property="pet" />
</section>
<repeat foreach="companies">
    <section title="name">
        <row label="address" property="address" />
        <row label="email" property="email" />
    </section>
</repeat>

至于<repeat>标签之间的部分,我打算为数组中的每个条目循环遍历此部分0到n次。然而,NSXMLParser似乎没有一种简单的方法可以做到这一点。我看不到跳回前一行的选择。我能想到的唯一方法是在变量中的<repeat>标签之间存储所有内容,并在解析器中执行自定义解析和重复:didEndElement:...方法。我不知道,是不是有更好的方法可以做到这一点?

0 个答案:

没有答案