Note that there are some explanatory texts on larger screens.

plurals
  1. POI am not able to parse xml data using GDataXML
    primarykey
    data
    text
    <p>At first i have imported <code>#import "GDataXMLNode.h"</code> in .h file. Now this is my <code>XML</code> which i have to parse using <code>GDataXML</code> parser.</p> <pre><code>&lt;SiteStats&gt; &lt;visitor&gt;1&lt;/visitor&gt; &lt;uniqueVisitor&gt;1&lt;/uniqueVisitor&gt; &lt;orderCount&gt;0&lt;/orderCount&gt; &lt;revenue&gt;null&lt;/revenue&gt; &lt;conversionRate&gt;0&lt;/conversionRate&gt; &lt;newProduct&gt;3&lt;/newProduct&gt; &lt;outOfStockProduct&gt;0&lt;/outOfStockProduct&gt; &lt;/SiteStats&gt; </code></pre> <p>Now, one thing to notice is that my this xml is coming from web. So I have used <code>NSUrlConnection</code> delegate to retrieve xml data.</p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection { responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@",responseString); // other stuff here... } </code></pre> <p>Here I get the <code>responseString</code> and then I parse it using the following code. But I'm not able to parse it.</p> <pre><code> xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:responseString options:0 error:&amp;errorOnStore]; if (nil == xmlDocument) { NSLog(@"could not load xml file"); } else { NSLog(@"Loading desire xml"); NSLog(@"%@", xmlDocument.rootElement); NSArray *getData = [[xmlDocument rootElement] elementsForName:@"SiteStats"]; NSLog(@"%@",getData); records = [[NSMutableArray alloc] init]; //[records retain]; if(getData.count !=0 ){ NSLog(@"data has"); } //storing the car model in the mutable array for(GDataXMLElement *e in getData){ NSLog(@"Enering in the xml file"); [records addObject:e]; NSString *Visitor = [[[e elementsForName:@"visitor"] objectAtIndex:0] stringValue]; NSLog(@"Visitor : %@",Visitor); NSString *UVisitor = [[[e elementsForName:@"uniqueVisitor"] objectAtIndex:0] stringValue]; NSLog(@"Unique Visitor : %@",UVisitor); } } </code></pre> <p>I can get this value when i <code>NSLog(@"%@", xmlDocument.rootElement);</code></p> <pre><code> GDataXMLElement 0x1a4290: {type:1 name:SiteStats xml:"&lt;SiteStats&gt;&lt;visitor&gt;4&lt;/visitor&gt;&lt;uniqueVisitor&gt;3&lt;/uniqueVisitor&gt;&lt;orderCount&gt;0&lt;/orderCount&gt;&lt;revenue&gt;0&lt;/revenue&gt;&lt;conversionRate&gt;0&lt;/conversionRate&gt;&lt;newProduct&gt;3&lt;/newProduct&gt;&lt;outOfStockProduct&gt;0&lt;/outOfStockProduct&gt;&lt;/SiteStats&gt;"} </code></pre> <p>But i use <code>NSLog(@"%@",getData);</code> I do not get any data in <code>getData</code> array.</p> <p>Can anybody tell me where is the problem? Thank you in advance.</p>
    singulars
    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.
 

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