function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RajiiiRajiii 

XMLStreamReader class's continue; statement not working

Hi all,

   I have one problem of 'continue;' statement.

      XmlStreamReader reader = new XmlStreamReader(docContent);

       while(reader.hasNext()){            
             if (reader.getEventType() == XmlTag.END_ELEMENT) {            
              continue;            
             }  

            elseif(reader.getEventType() == XmlTag.CHARACTERS                      
                 reader.getText();

            }

          reader.next();
          } 

    i want to when ever meet the event type is END_ELEMENT the loop will terminate and go to next iteration. we all knew that 'continue' could proceed as the same. but here the if(Red marking) condition only repeated till the limit exception(20000 times). but i want to only terminate the iteration which met condition. If i put break; means terminate the overall loop. what to do..

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Call next() before continue or restructure your code as an if-then-else setup.