0

I have an ASMX web service. It returns data in XML format . Data returned is large. Order of 30-40000 records. I am trying to use

TBXML.
<ArrayOfNAllAddresses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">

 &ltNAllAddresses&gt
   &ltAllAddID&gt60386 &lt/AllAddID&gt
    &ltAllAddressLine&gtXYZA Company </AllAddressLine&gt
    &ltAllAddressCity>&gtChicago  </AllAddressCity&gt
    &ltAllAddressState&gtIL </AllAddressState&gt
    &ltAllAddressZip&gt5555</AllAddressZip&gt
    &ltAllCustID &gt41257> </AllCustID&gt
  &lt/NAllAddresses&gt
 &ltNAllAddresses&gt
....

  </NAllAddresses>
 </ArrayOfNAllAddresses>

     TBXMLElement *elem_NAddresses = [TBXML childElementNamed:@"ArrayOfNAllAddresses" parentElement:root];
        NSLog(@"the value is at 873 %@",elem_NAddresses);
        while (elem_NAddresses != nil) {
    //It should enter here. But it won't
    }

So i tried it. But it won't enter the while loop. I changed the value from ArrayOfNAlllAddresses to use NALLAddresses. But it won't work in either. Can someone tell me how to parse it?Thanks. If you need more info let me know.

Deepesh
  • 8,065
  • 3
  • 28
  • 45
RookieAppler
  • 1,517
  • 5
  • 22
  • 58

1 Answers1

0

Did you pass the XML file to TBXML at any point? You need to do that first, otherwise TBXML has no idea what XML you are talking about. So save your XML in a .xml file in Xcode or make it into an NSString and pass it to TBXML like so:

TBXML *tbxml = [TBXML tbxmlWithXMLFile:@"yourFile.xml"];
//or
TBXML *tbxml = [TBXML tbxmlWithXMLString:yourString]

Then you can grab the root element and do your while loop:

TBXMLElement *root = tbxml.rootXMLElement;

Also, make sure you #include the TBXML.h header file.

Maarten
  • 1,873
  • 1
  • 13
  • 16