我正在编写一些代码来将问题解析为对象。我正在使用 NSXMLParser。问题是,我也格式化了自己的 XML 数据,我认为是不正确的。
<?xml version="1.0" encoding="UTF-8"?>
<factor value="1">
<key value="plus">
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
</key>
<key value="minus">
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
</key>
</factor>
<factor value="2">
<key value="plus">
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
</key>
<key value="minus">
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
<question>PLACEHOLDER_TEXT</question>
</key>
</factor>
那就是我正在解析的xml。问题进行到一半,解析器给了我
Error Domain=NSXMLParserErrorDomain Code=5 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 5.)"
我的问题:如何格式化,以便正确解析整个文档。最终结果是拥有一个问题托管对象,其属性为:key 和 factor。