views:

33

answers:

2

Hey everbody, I'm getting some trouble with TBXML and While. I'm trying to parse a couple of nodes of XML. My XML is this:

<teste> 

1 2 3

But when I set while, my app just crashes.

    itemsList = [[NSMutableArray alloc] init];

 TBXML * tbxml = [[TBXML tbxmlWithURL:[NSURL URLWithString:@"http://localhost/dev/http/test.xml"]] retain];
 TBXMLElement * rootXMLElement = tbxml.rootXMLElement;

 TBXMLElement * comentarios = [TBXML childElementNamed:@"comentarios" parentElement:rootXMLElement];

 while (comentarios != nil) {
  TBXMLElement * comentario = [TBXML childElementNamed:@"comentario" parentElement:comentarios];

  NSString * descText = [TBXML textForElement:comentario];

  [itemsList addObject:descText];

}

What im doing wrong?

A: 

I want to count how many nodes are in comentarios

<comentarios>
<comentario>1</comentario>
<comentario>2</comentario>
<comentario>3</comentario>
</comentarios>

And put in a TableView. Actually, im getting only the first node. I want get all.

Lucas Veiga