我有其中包含了一些数据,我想用一个XML文件:解析XML文件 - 获取值
<?xml version="1.0" encoding="UTF-8" ?>
<items>
<item name="product" price="19.95" where="store">
This is the first product.
</item>
<item name="product2" price="39.95" where="online">
This is the second product.
</item>
<item name="product3" price="99.95" where="garagesale">
This is the third product.
</item>
</items>
如果我做了4个阵列,一个名字,一个是价格,一个用于购买它的地方,一个用于描述,我如何将数据存入数组?
我想通过使用NSXMLParser,但不能得到name
,price
,where
或描述。
我被困在如何做到这一点。
任何帮助表示赞赏。
你读过[the guide](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/XMLParsing/Articles/HandlingElements.html)吗? – 2011-05-21 12:17:45
[在iPhone上进行XML解析的最佳方法]的可能重复(http://stackoverflow.com/questions/842292/best-approach-for-xml-parsing-on-the-iphone)或[Simple XML Parsing]( http://stackoverflow.com/questions/3616447/parsing-xml-code-on-iphone-sdk(http://stackoverflow.com/questions/3616447/parsing-xml-code-on-iphone-sdk)解决XML的问题(http://stackoverflow.com/questions/3616447/parsing-xml-code-on-iphone-sdk) )或[在可可中解析XML](http://stackoverflow.com/questions/1089737/parsing-xml-in-cocoa)或[NSXMLParser on iPhone如何使用它?](http://stackoverflow.com/问题/ 2964503 /)。拿你的选择。 – 2011-05-21 17:06:31
这是一个很好的教程,但有一件事我没有得到帮助。你能告诉我,我怎样才能读取字符串“这是第一个产品”。 – 2012-04-08 15:53:31