开发者

Parsing XML using Objective C

I am new to Objective C programming, i need your help to solve my problem in parsing xml. I have consumed a WCF Res开发者_StackOverflow中文版tful service, the service returns a xml formatted string.

The XML format is as below:

<Content>
<Category Id="1" Name="Software">
 <Category Id="2" Name="Windows 7"/>
</Category>
<Category Id="3" Name="Hardware">
 <Category Id="4" Name="Printers"/>
</Category>
</Content>

I am trying to retrieve the parent node in a array and child nodes in another array.

When i use:

NSArray *nodes=nil;
nodes=[doc nodesForXPath:@"//Category" error:nil]; 

All the node details having the node Category comes in the array. But the child item of name Category should not come in parent list.

Please suggest me how to get only the parent node in a collection, and the child nodes in another collection.


you can use NSXMLParser for that. it is a SAX Parser. You can Find Some more Dom and SAX parser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜