Search code examples
iosobjective-cxmlxml-parsingtouchxml

Getting duplicate children in TouchXML


I have a CXMLDocument and the problem is that when I do this:

for (CXMLElement* auxitem in [doc children]){
    NSLog(@"NAME: %@", auxitem);
}

It gives me an empty CXMLNode and the CXMLElement with the information I want, like this:

2013-01-25 19:12:58.607 ClienteF[2438:c07] NAME: <CXMLNode 0x72ba5f0 [0x72ba900] text>
2013-01-25 19:12:58.607 ClienteF[2438:c07] NAME: <CXMLElement 0x72ba640 [0x72ba950] node        <node label="NAME" description="DESCRIPTION" id="1"> 

I only want to get the CXMLElement because it's the one with the information. How can I discard the CXMLNode? Of course I thought about get only the even numbers of the for but I'm looking for other alternative.

Thanks.


Solution

  • I have done this:

    for (CXMLElement* auxitem in [doc children]){
        if([[auxitem localName] isEqualToString:@"node"]){
            NSLog(@"NAME: %@", auxitem);
        }
    }
    

    Maybe it isn't the best solution but It works. Any idea more will be great.