How to add NSXML parser in class?
<p>I want  to add NSXML parser in to my Objective-C class and parse XML file</p>

<p>in .h file</p>

<pre><code>NSMutableData *myWebData; NSXMLParser *myXMLParser; NSString *tempStr;
</code></pre>

<p>in .m life</p>

<pre><code>    (void)ViewDidLoad
    {
    NSString *soapMsg=@"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n"
        "&lt;soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;\n"
        "&lt;soap:Body&gt;\n"
        "&lt;GetCountryList xmlns=\"http://tempuri.org/\" /&gt;"
        "&lt;/soap:Body&gt;"
        "&lt;/soap:Envelope&gt;";

        NSURL *myurl=[NSURL URLWithString:@"http://iphone.dotnetdemosite.com/Health4Life/Health4Life_Service.asmx?op=GetCountryList"];
        NSMutableURLRequest *connectionReq=[NSMutableURLRequest requestWithURL:myurl];

        [connectionReq addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
        [connectionReq addValue:@"http://tempuri.org/GetCountryList" forHTTPHeaderField:@"SOAPAction"];
        [connectionReq setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
        [connectionReq addValue:[NSString stringWithFormat:@"%i",[soapMsg length]] forHTTPHeaderField:@"Content-Length"];
        [connectionReq setHTTPMethod:@"POST"];



        NSURLConnection *myConnection=[[NSURLConnection alloc] initWithRequest:connectionReq delegate:self];
        if (myConnection) {
            myWebData=[[NSMutableData alloc]initWithLength:0];
        }
    }

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"connection error");
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [myWebData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{ 
    [myWebData appendData:data];

}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSString *str=[[NSString alloc] initWithBytes:[myWebData bytes] length:[myWebData length] encoding:NSStringEncodingConversionAllowLossy];
    NSLog(@"%@",str);
    [str release];

    if(myXMLParser!=nil &amp;&amp; [myXMLParser retainCount]&gt;0)
    { 
        myXMLParser.delegate=nil; 
        [myXMLParser release]; 
        myXMLParser=nil; 
    }

    myXMLParser=[[NSXMLParser alloc] initWithData:myWebData];
    myXMLParser.delegate=self;
    [myXMLParser parse];

    [connection release];
    [myWebData release];
}

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
///////////////       logic here
}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if(tempStr!=nil &amp;&amp; [tempStr retainCount]&gt;0)
    {  
        [tempStr release]; tempStr=nil;
    }
    tempStr=[[NSString alloc] initWithString:string];
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
///////////////logic here
}

- (void)parserDidEndDocument:(NSXMLParser *)parser
{
    //NSLog(@"%@",[countryArray description]);
//  NSLog(@"%@",[stateArray description]);
//  NSLog(@"%@",[cityArray description]);
    //NSLog(@"%@",[tempstate description]);
    /////////////////////          print array if you want in this you will get all data in array ,
    //[(UITableView *)self.view reloadData];
}
</code></pre>
