Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to parse data using below xml data in iPhone
    primarykey
    data
    text
    <p>I am new to i phone programming.I have xml data which i have show as below.Using that data i want to display particular date data having 2 tables how can i display particular date data in single row.In next data 2012-06-20 having 3 tables how can i display 3tables data in second row.How can i parse that data,Tell me logic for that </p> <pre><code>&lt;Result&gt; &lt;Table diffgr:id="Table1" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T09:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;1&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;100.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table2" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T10:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;1&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;100.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table3" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T09:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;2&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;200.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table4" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T10:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;2&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;200.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table5" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T11:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;2&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;200.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table6" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T09:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;3&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;150.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Table&gt; &lt;Table diffgr:id="Table7" msdata:rowOrder="2"&gt; &lt;CafeDateTime&gt;2012-09-19T10:01:54-06:00&lt;/CafeDateTime&gt; &lt;CreatedBy&gt;3&lt;/CreatedBy&gt; &lt;Email&gt;YOURMAIL@CAFE.COM&lt;/Email&gt; &lt;AdminPassword&gt;admin1&lt;/AdminPassword&gt; &lt;SalesDailyAmount&gt;150.0000&lt;/SalesDailyAmount&gt; &lt;PurchasesDailyAmount&gt;0.0000&lt;/PurchasesDailyAmount&gt; &lt;/Table&gt; &lt;/Result&gt; 2012-09-19 -&gt;Having 2 tables(i.e Table1,Table2) 2013-09-20 -&gt;Having 3 tables(i.e Table3,Table4,Table5) 2013-09-21 -&gt;Having 2 tables(i.e Table6,Table7) </code></pre> <p>Now what is my question is In above xml data i have total 7 tables in that table1,table2 data belong to 2012-09-19 date.I want to parse data and display in view like this below</p> <pre><code> CreateBy SalesDailyAmount PurchasesDailyAmount 2012-09-19 -&gt;Want to display 1 100 0.0000 </code></pre> <p>Using below code</p> <pre><code>-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName attributes: (NSDictionary *)attributeDict { if( [elementName isEqualToString:@"CreateBy"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } xmlResults = YES; } if( [elementName isEqualToString:@"SalesDailyAmount"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } xmlResults = YES; } if( [elementName isEqualToString:@"PurchasesDailyAmount"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } xmlResults = YES; } } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if( xmlResults ) { [soapResults appendString: string]; NSLog(@"soap result %@",soapResults); [arr_detail addObject:soapResults]; NSLog(@"gg %@",arr_detail); NSLog(@"gcvxg %@",arr_info); } [tableView reloadData]; } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if( [elementName isEqualToString:@"CreateBy"]) { xmlResults = FALSE; [aslam4 addObject:soapResults]; NSLog(@"hello %@",aslam4); soapResults = nil; } if( [elementName isEqualToString:@"SalesDailyAmount"]) { xmlResults = FALSE; [aslam5 addObject:soapResults]; NSLog(@"hello %@",aslam5); soapResults = nil; } if( [elementName isEqualToString:@"PurchasesDailyAmount"]) { xmlResults = FALSE; [aslam6 addObject:soapResults]; NSLog(@"hello %@",aslam6); soapResults = nil; } } } </code></pre> <p>Using above code i can able to get data like this below</p> <pre><code> OutPut CreateBy SalesDailyAmount PurchasesDailyAmount 1 100 0.0000 1 100 0.0000 2 200 0.0000 2 200 0.0000 2 200 0.0000 3 150 0.0000 3 150 0.0000 </code></pre> <p>But i want to display like this below</p> <pre><code> CreateBy SalesDailyAmount PurchasesDailyAmount 2012-09-19 -&gt;Want to display 1 100 0.0000 2012-09-20 -&gt;Want to display 2 200 0.0000 2012-09-21 -&gt;Want to display 3 150 0.0000 </code></pre> <p>I don't want to display multiple time.In 2012-09-19 having 2 tables but both having same data but i don't want to display multiple times. similarly 2012-09-20 having 3tables here also i don't want to display 3 times i want to display in 3tables data in one row. Overall i want to say that Right now in array its storing data like this below Array ={100,100,200,200,200,150,150} but i don't want like this i want to store like this Array ={100,200,150} Can please tell me how to write logic for that.</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.
    1. This table or related slice is empty.
    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