Reputation: 39
I have this XML :
<xml encoding="UTF-8">
<URLs>
<contentTypes>
<ROW1>
<link>www.google.com</link>
<link>www.hotmail.com</link>
<link>www.yahoo.com</link>
<link>www.microsoft.com</link>
</ROW1>
</contentTypes>
</URLs>
Now, I want to extract the links and store them in array using TBXML in objective-c.
Thankx in advance,
Upvotes: -2
Views: 140
Reputation: 329
@Ahmer Mli: I would assume you already know how to parse the xml using TBXML. Here is a test code that would help in your case:
NSMutableArray links = [[NSMutableArray alloc] init];
TBXMLElement *rowLink; //I assume you already knew how to get to the <ROW1> element;
TBXMLElement *linkElement = rowLink->firstChild;
if (linkElement)
{
do
{
if ([[TBXML elementName:linkElement] isEqualString@"link"])
{
[links addObject:[TBXML textForElement:linkElement]];
}
}((linkElement = linkElement->nextSibling));
}
Upvotes: 0