如何解析在Objective-C XML属性? [英] How to parse xml attributes in objective-c?

查看:126
本文介绍了如何解析在Objective-C XML属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的XML是这样的:

<Schedule id="1296" date="2010-05-20">
−
<Sports>
<Sport id="1" name="Football" abbr="FB"/>
<Sport id="2" name="Basketball" abbr="BK"/>
<Sport id="3" name="Baseball" abbr="BB"/>
<Sport id="4" name="Hockey" abbr="HK"/>
<Sport id="5" name="Other" abbr="OT"/>
</Sports>
−
<Leagues>
<League id="1" league_id="1" sport_id="1" periods="4" half_time_minutes="12" name="NFL" abbr="NFL" covers_league="NFL" covers_sport="football"/>
<League id="2" league_id="2" sport_id="1" periods="4" half_time_minutes="18" name="College Football" abbr="CFB" covers_league="NCAAF" covers_sport="football"/>
<League id="3" league_id="3" sport_id="2" periods="4" half_time_minutes="15" name="NBA" abbr="NBA" covers_league="NBA" covers_sport="basketball"/>
<League id="4" league_id="4" sport_id="2" periods="2" half_time_minutes="15" name="College Basketball" abbr="CBK" covers_league="NCAAB" covers_sport="basketball"/>
<League id="5" league_id="5" sport_id="3" periods="9" half_time_minutes="0" name="MLB" abbr="MLB" covers_league="MLB" covers_sport="baseball" ml="true"/>
<League id="6" league_id="6" sport_id="3" periods="9" half_time_minutes="0" name="College Baseball" abbr="CBB" ml="true"/>
<League id="7" league_id="7" sport_id="4" periods="3" half_time_minutes="0" name="NHL" abbr="NHL" covers_league="NHL" covers_sport="hockey" ml="true"/>
<League id="8" league_id="8" sport_id="2" periods="4" half_time_minutes="15" name="WNBA" abbr="WNBA" covers_league="WNBA" covers_sport="basketball"/>
</Leagues>

我怎么可以在这个XML解析值?

how can i parse the values in this xml?

推荐答案

使用的NSXMLParser ..试试下面这个教程:

Use NSXMLParser.. Try following this tutorial:

<一个href=\"https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/XMLParsing/XMLParsing.html#//apple_ref/doc/uid/10000186-SW1\"相对=nofollow>上的NSXMLParser 编程指南

这篇关于如何解析在Objective-C XML属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆