Note that there are some explanatory texts on larger screens.

plurals
  1. POWebservice data is not loading in NSXMLParse in iphone
    primarykey
    data
    text
    <p>I am new to i phone programming.I am getting some response from webservice.But its not loading that data in nsxmlparser.</p> <h1>import "ViewController.h"</h1> <pre><code>@interface ViewController : UIViewController&lt;UITableViewDelegate,UITableViewDataSource,NSXMLParserDelegate,NSURLConnectionDelegate&gt; { NSMutableData *webData; NSMutableString *soapResults; NSXMLParser *xmlParser; BOOL xmlResults; NSMutableArray *arr_code,*arr_name; } @property(nonatomic,retain)NSMutableArray *arr_code,*arr_name; @property(nonatomic,retain)NSMutableData *webData; @property(nonatomic,retain)NSMutableString *soapResults; @property(nonatomic,retain)NSXMLParser *xmlParser; </code></pre> <h1>import "ViewController.h"</h1> <pre><code>@synthesize arr_code,arr_name,webData,soapResults,xmlParser,nb,table; - (void)viewDidLoad { arr_code=[[NSMutableArray alloc]init]; arr_name=[[NSMutableArray alloc]init]; xmlResults =FALSE; NSString *soapMessage=[NSString stringWithFormat: @"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n" "&lt;soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;\n" "&lt;soap:Body&gt;\n" "&lt;OnlineStatus xmlns=\"http://tempuri.org/\"&gt;\n" "&lt;CafeName&gt;Cyber Cafe Name&lt;/CafeName&gt;\n" "&lt;FromDate&gt;2012-03-01&lt;/FromDate&gt;\n" "&lt;ToDate&gt;2013-05-03&lt;/ToDate&gt;&lt;/OnlineStatus&gt;\n" "&lt;/soap:Body&gt;\n" "&lt;/soap:Envelope&gt;"]; NSLog(@"%@",soapMessage); NSURL *url = [NSURL URLWithString:@"http://www.ebidmanagerdemo.com/gjHouseOnline/xml/XMLDataService.asmx"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: @"http://tempuri.org/OnlineStatus" forHTTPHeaderField:@"Soapaction"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if(theConnection) { webData = [NSMutableData data]; } else { NSLog(@"theConnection is NULL"); NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; NSLog(@"%@",msgLength); [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConnenction"); } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; theXML = [theXML stringByReplacingOccurrencesOfString:@"&amp;lt;" withString:@"&lt;"]; theXML = [theXML stringByReplacingOccurrencesOfString:@"&amp;gt;" withString:@"&gt;"]; theXML = [theXML stringByReplacingOccurrencesOfString:@"&amp;amp;" withString:@"&amp;"]; NSLog(@" getting in xml %@",theXML); NSLog(@"XMl is workinggggggggg"); xmlParser = [[NSXMLParser alloc]initWithData:webData]; NSXMLParser *aslamxml =[[NSXMLParser alloc]initWithData:dataa]; [xmlParser setShouldResolveExternalEntities: YES]; [xmlParser setDelegate: self]; [xmlParser parse]; NSLog(@" iiiiii %@",xmlParser); } -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName attributes: (NSDictionary *)attributeDict { NSLog(@"fsdfsd"); if( [elementName isEqualToString:@"MachineIP"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } xmlResults = YES; } else { if( [elementName isEqualToString:@"MachineIP"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } xmlResults = YES; } } } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if( xmlResults ) { [self.soapResults appendString: string]; NSLog(@"soap result %@",soapResults); } } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if( [elementName isEqualToString:@"MachineIP"]) { xmlResults = FALSE; [arr_code addObject:soapResults]; // NSLog(@"hello %@",arr_code); soapResults = nil; } else { if( [elementName isEqualToString:@"MachineIP"]) { xmlResults = FALSE; [arr_name addObject:soapResults]; NSLog(@"hiii %@",arr_name); soapResults = nil; } } [table reloadData]; } </code></pre> <p>I am getting output like this If i give NSLog(@" getting in xml %@",theXML); In console its displaying below think</p> <pre><code>2013-05-27 19:13:35.735 NewC Newcafezee[1202:11303] DONE. Received Bytes: 18345 2013-05-27 19:13:35.737 NewC Newcafezee[1202:11303] getting in xml &lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;OnlineStatusResponse xmlns="http://tempuri.org/"&gt;&lt;OnlineStatusResult&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;DataSet&gt; &lt;xs:schema id="Result" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt; &lt;xs:element name="Result" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"&gt; &lt;xs:complexType&gt; &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:element name="Table"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="SystemDateTime" type="xs:dateTime" minOccurs="0" /&gt; &lt;xs:element name="CafeDateTime" type="xs:dateTime" minOccurs="0" /&gt; &lt;xs:element name="LicenseNumber" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="MachineIP" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="TotalClients" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="IdleClients" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="BusyClients" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="DummyIdle" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="DummyBusy" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="PCUsageSessions" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="PCUsageMinutes" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="SessionMessage" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="CreatedBy" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="CreatedDate" type="xs:dateTime" minOccurs="0" /&gt; &lt;xs:element name="Cybercafe" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="Email" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="AdminPassword" type="xs:string" minOccurs="0" /&gt; &lt;xs:element name="MajorVersion" type="xs:short" minOccurs="0" /&gt; &lt;xs:element name="MinorVersion" type="xs:short" minOccurs="0" /&gt; &lt;xs:element name="SalesAmount" type="xs:decimal" minOccurs="0" /&gt; &lt;xs:element name="PurchasesAmount" type="xs:decimal" minOccurs="0" /&gt; &lt;xs:element name="Revision" type="xs:int" minOccurs="0" /&gt; &lt;xs:element name="CZLicense" type="xs:string" minOccurs="0" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:choice&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; &lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt; &lt;Result&gt; &lt;Table diffgr:id="Table1" msdata:rowOrder="0"&gt; &lt;SystemDateTime&gt;2012-09-20T00:00:00-06:00&lt;/SystemDateTime&gt; &lt;CafeDateTime&gt;2012-09-18T11:01:54-06:00&lt;/CafeDateTime&gt; &lt;LicenseNumber&gt;cc&lt;/LicenseNumber&gt; &lt;MachineIP&gt;192.168.13.167&lt;/MachineIP&gt; &lt;TotalClients&gt;0&lt;/TotalClients&gt; &lt;IdleClients&gt;0&lt;/IdleClients&gt; &lt;BusyClients&gt;0&lt;/BusyClients&gt; &lt;DummyIdle&gt;0&lt;/DummyIdle&gt; &lt;DummyBusy&gt;0&lt;/DummyBusy&gt; &lt;PCUsageSessions&gt;0&lt;/PCUsageSessions&gt; &lt;PCUsageMinutes&gt;0&lt;/PCUsageMinutes&gt; &lt;SessionMessage&gt;LVCLPRLbSCTC&lt;/SessionMessage&gt; &lt;CreatedBy&gt;1&lt;/CreatedBy&gt; &lt;CreatedDate&gt;2012-09-20T00:00:00-06:00&lt;/CreatedDate&gt; &lt;Cybercafe&gt;Cyber Cafe Name&lt;/Cybercafe&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;MajorVersion&gt;1&lt;/MajorVersion&gt; &lt;MinorVersion&gt;0&lt;/MinorVersion&gt; &lt;SalesAmount&gt;0.0000&lt;/SalesAmount&gt; &lt;PurchasesAmount&gt;0.0000&lt;/PurchasesAmount&gt; &lt;Revision&gt;0&lt;/Revision&gt; &lt;CZLicense /&gt; &lt;/Table&gt; &lt;/Result&gt; &lt;/diffgr:diffgram&gt; &lt;/DataSet&gt;&lt;/OnlineStatusResult&gt;&lt;/OnlineStatusResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt; </code></pre> <p>But if give NSLog(@" iiiiii %@",xmlParser); it is for XMLParser its not loading in NSXMlparser its showing empty please Can any body tell me that what is mistake in this code?I am not getting why its not loading in NSXMLparser.</p> <pre><code>2013-05-27 19:13:35.738 NewC Newcafezee[1202:11303] XMl is workinggggggggg 2013-05-27 19:13:35.739 NewC Newcafezee[1202:11303] iiiiii &lt;NSXMLParser: 0x7191d20&gt; </code></pre> <p>I am getting error code some think like this below</p> <pre><code>2013-05-27 19:43:35.962 NewC Newcafezee[1291:11303] error parsing XML: Unable to download story feed from web site (Error code 64 ) http://www.ebidmanagerdemo.com/gjHouseOnline/xml/XMLDataService.asmx </code></pre> <p>In above output i am getting two time below code</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p>That is main reason for error ra?please tell me what is mistake?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload