我有一个NSXMLDocument的元素(一个FCPX导出的.fcpxml)我想要走过,而不是让孩子们,然后是嵌套的孩子,等等:
<spine>
<clip name="Referee" offset="0s" duration="5s" format="r2" tcFormat="NDF">
<video offset="0s" ref="r3" duration="418132800/90000s">
<audio lane="-2" offset="0s" ref="r3" srcID="2" duration="3345062400/720000s" role="dialogue" srcCh="1, 2"/>
<audio lane="-1" offset="0s" ref="r3" duration="3345062400/720000s" role="dialogue" srcCh="1, 2"/>
</video>
<spine lane="1" offset="119/25s" format="r1">
<clip name="Referee" offset="0s" duration="403200/90000s" start="1300/2500s" format="r2" tcFormat="NDF">
<adjust-volume amount="-96dB"/>
<video offset="0s" ref="r3" duration="418132800/90000s">
<audio lane="-2" offset="0s" ref="r3" srcID="2" duration="3345062400/720000s" role="dialogue" srcCh="1, 2"/>
<audio lane="-1" offset="0s" ref="r3" duration="3345062400/720000s" role="dialogue" srcCh="1, 2"/>
</video>
</clip>
<transition name="Cross Dissolve" offset="313200/90000s" duration="1s">
<filter-video ref="r4" name="Cross Dissolve">
<param name="Look" key="1" value="11 (Video)"/>
<param name="Amount" key="2" value="50"/>
<param name="Ease" key="50" value="2 (In & Out)"/>
<param name="Ease Amount" key="51" value="0"/>
</filter-video>
<filter-audio ref="r5" name="Audio Crossfade"/>
</transition>
</spine>
</clip>
<transition name="Cross Dissolve" offset="4s" duration="1s">
<filter-video ref="r4" name="Cross Dissolve">
<param name="Look" key="1" value="11 (Video)"/>
<param name="Amount" key="2" value="50"/>
<param name="Ease" key="50" value="2 (In & Out)"/>
<param name="Ease Amount" key="51" value="0"/>
</filter-video>
<filter-audio ref="r5" name="Audio Crossfade"/>
</transition>
</spine>
我认为使用NSXMLParser是最好的选择,所以我有一个这样的:
NSXMLParser *new_parser = [[NSXMLParser alloc] initWithData:[NSData dataWithBytes:[[theXMLElement stringValue] UTF8String] length:[theXMLElement stringValue].length]];
[new_parser setDelegate:self];
BOOL parse_success = [new_parser parse];
但它失败了,因为元素的-stringValue
返回零长度字符串(使用NSLog输出检查)。那么我应该如何设置解析更大的NSXMLDocument的上述元素(或类似的)?
答案 0 :(得分:0)
我应该使用-XMLString
来获取解析器的有效字符串。我在某个地方见过-stringValue
而且它已经卡在了我脑海里。