Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to check end element with empty tag on iPhone?
    primarykey
    data
    text
    <p>I'm newbie on iPhone development.I want to parse XML file like this to get attribute value.</p> <pre><code> &lt;Root&gt; &lt;element att_1 ="value1" att_2 ="value2" /&gt; &lt;element att_1 ="value1" att_2 ="value2" /&gt; . . . &lt;Root/&gt; </code></pre> <p>Normally XML file </p> <pre><code> &lt;element att="..."&gt; content &lt;element/&gt; </code></pre> <p>I use this at didEndElement</p> <pre><code> if([elementName isEqualToString:@"element"]){ // Do something } </code></pre> <p>How to check empty tag ? Advice me Please. Thank you.</p> <p>sorry for my bad english.</p> <p>=====================================================================</p> <p>Now I have new problem.when I run the application(simulator) it stuck and show message"Thread1:Stopped at breakpoint" in didStartElement.I guess I do something wrong.</p> <p>StudyList.xml</p> <pre><code> &lt;StudyList&gt; &lt;study description="20040311181130" modsInStudy="" pat_birth="19760822" pat_id="47-3450" pat_name="Ekachai Chaichanasiri" refPhy="" study_date="Sun Jan 11 00:03:00 ICT 2004" study_id="696122224" study_iuid="1.2.392.200036.9123.100.200.20040311181130"/&gt; &lt;study description="XoranCAT Study" modsInStudy="" pat_birth="19821117" pat_id="63" pat_name="Wantana Areeprayolkij" refPhy="" study_date="Fri Jan 28 00:04:00 ICT 2005" study_id="" study_iuid="1.2.826.0.1.3680043.2.594.4041.16900.9840.32723.30648"/&gt; &lt;/StudyList&gt; </code></pre> <p>Delegate</p> <pre><code> -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ if ([elementName isEqualToString:@"StudyList"]) { //Initialize the array. appDelegate.studyList = [[NSMutableArray alloc] init]; } else if ([elementName isEqualToString:@"study"]) { //Initialize the study. aStudy.patientBrith = [attributeDict objectForKey:@"pat_birth"] ; aStudy.patientID = [attributeDict objectForKey:@"pat_id"]; aStudy.patientName = [attributeDict objectForKey:@"pat_name"]; aStudy.studyDate = [attributeDict objectForKey:@"study_date"]; NSLog(@"Patient name: %@",aStudy.patientName); NSLog(@"Patient ID: %@",aStudy.patientID); NSLog(@"Patient Birth: %@" ,aStudy.patientBrith); NSLog(@"Study Date: %@" ,aStudy.studyDate); } NSLog(@"Process Element"); } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ //Nothing to do because XML file dose not have text node } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ //End if XML file nothing to do. if ([elementName isEqualToString:@"StudyList"]) { return; //Add study object in to array and release the object. if ([elementName isEqualToString:@""]||elementName == nil) { [appDelegate.studyList addObject:aStudy]; } } } </code></pre> <p>NSLog(@"Patient name: %@",aStudy.patientName);</p> <p>NSLog(@"Patient ID: %@",aStudy.patientID);</p> <p>NSLog(@"Patient Birth: %@" ,aStudy.patientBrith);</p> <p>NSLog(@"Study Date: %@" ,aStudy.studyDate);</p> <p>***Output of above is null. What wrong,Please tell me in right way.</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