在iOS中解析XML
以读文件的形式
iOS中的XML是event-driven模式
1:打开一个xml文件,读取内容到NSData中
2:调用NSXMLParse的nitWithData方法,并设置代理tweetParser.delegate = self;
3:调用回调函数
注意:xml文件的第一个tag必须要顶格写!
<?xml version="1.0"encoding="UTF-8"?>
<bookstore>
<book catalog="Programming">
<title lang="en">C++ ProgrammingLanguage</title>
<author>Bjarne Stroustrup</author>
<year>1998</year>
<price>98.0</price>
</book>
<book catalog="Networking">
<title lang="en">TCP/IP Illustrated</title>
<author>Richard Stevens</author>
<year>1996</year>
<price>56.0</price>
</book>
</bookstore>
<?xml version="1.0"encoding="UTF-8"?>
<bookstore>
<book catalog="Programming">
<title lang="en">C++ Programming Language</title>
<author>Bjarne Stroustrup</author>
<year>1998</year>
<price>98.0</price>
</book>
<book catalog="Networking">
<title lang="en">TCP/IP Illustrated</title>
<author>Richard Stevens</author>
<year>1996</year>
<price>56.0</price>
</book>
</bookstore>

浙公网安备 33010602011771号