Note that there are some explanatory texts on larger screens.

plurals
  1. POXML parsing - iPhone
    primarykey
    data
    text
    <p>Hello I am new to iPhone development. I have created one application that consume data from web service. And it works fine but I have a problem with parsing.</p> <p>The xml data that I get from the web service is:</p> <pre><code>&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt; &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt; &lt;p&gt;Severity: Warning&lt;/p&gt; &lt;p&gt;Message: session_start() [&lt;a href='function.session-start'&gt;function.session-tart&lt;/a&gt;]: Cannot send session cookie - headers already sent by (output started at D:\xampp\htdocs\system \application\controllers\isignin.php:4)&lt;/p&gt; &lt;p&gt;Filename: libraries/session.php&lt;/p&gt; &lt;p&gt;Line Number: 146&lt;/p&gt; &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt; &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt; &lt;p&gt;Severity: Warning&lt;/p&gt; &lt;p&gt;Message: session_start() [&lt;a href='function.session-start'&gt;function.session-start&lt;/a&gt;]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\6d\system \application\controllers\isignin.php:4)&lt;/p&gt; &lt;p&gt;Filename: libraries/session.php&lt;/p&gt; &lt;p&gt;Line Number: 146&lt;/p&gt; &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt; &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt; &lt;p&gt;Severity: Warning&lt;/p&gt; &lt;p&gt;Message: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\6d\system\application\controllers\isignin.php:4)&lt;/p&gt; &lt;p&gt;Filename: codeigniter/Common.php&lt;/p&gt; &lt;p&gt;Line Number: 360&lt;/p&gt; &lt;/div&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xml&gt;&lt;item&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;newblock&amp;gt;&amp;lt;name&amp;gt;abcde &amp;lt;/name&amp;gt;&amp;lt;password&amp;gt;12345678&amp;lt;/password&amp;gt;&amp;lt;/newblock&amp;gt;&lt;/item&gt;&lt;/xml&gt; </code></pre> <p>This is what I call from connectionDidFinishLoading method:</p> <pre><code>-(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); if (xmlParser) { [xmlParser release]; } xmlParser = [[NSXMLParser alloc] initWithData: webData]; [xmlParser setDelegate: self]; [xmlParser setShouldResolveExternalEntities:YES]; [xmlParser parse]; [connection release]; [webData release]; } </code></pre> <p>The following are the parsing methods used:</p> <pre><code>-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *) qName attributes:(NSDictionary *) attributeDict { if( [elementName isEqualToString:@"GetWeatherResult"]) { if (!soapResults) { soapResults = [[NSMutableString alloc] init]; } elementFound = YES; } } -(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string { if (elementFound) { [soapResults appendString: string]; } } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"GetWeatherResult"]) { //---displays the country--- NSLog(soapResults); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Current Temperature!" message:soapResults delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; [soapResults setString:@""]; elementFound = FALSE; } } </code></pre> <p>My query is : I want to extract the <strong>"name" tag</strong> with value <strong>"abcde"</strong> from the received XML data.<br> But when I search for <strong>"name"</strong> with value <strong>"abcde"</strong> in the above xml data received, parser can't find it because of <strong>&amp;qt, &amp;lt</strong> etc. </p> <p>1) How to fix my NSMutableData to have normal values (&lt;, > etc.)? Any inbuilt functions of NSMutableData to replace <strong>&amp;lt, &amp;gt</strong> with <strong>&lt;, ></strong>? Or<br> 2) Is there any thing missing (or doing wrong) while generating the xml data at the server side or Am I missing anything while parsing at the client side (on iPhone) Or<br> 3) Any other solution to fix the above problem. </p> <p>Thanks in advance.</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.
    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