Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* ************************************************************************
 #
 #  DivConq
 #
 #  http://divconq.com/
 #
 #  Copyright:
 #    Copyright 2014 eTimeline, LLC. All rights reserved.
 #
#  License:
#    See the license.txt file in the project's top-level directory for details.
#  Authors:
#    * Andy White
************************************************************************ */
package divconq.xml;
public class XmlStreamer {
	static public OperationResult parseStream(String pathint levelIPartHandler handlerboolean keepwhitespace) {
		try {
			// load names
			BufferedReader bReader = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
			 XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(bReader);
			 
			 int clevel = 0;
			 
			 while (xmlStreamReader.hasNext()) {
				 int n = xmlStreamReader.next();
			        
				 switch (n) {
					 if (level == clevel) {
						 XElement part = new XElement(xmlStreamReaderkeepwhitespace);
						 handler.part(part);
						 //clevel--;
					 }
					 else
						 clevel++;
					 break;
					 clevel--;
					 break;
				 }
			 }
			 
			 xmlStreamReader.close();		
		}
		catch (Exception x) {
			..println("error reading xml stream: " + x);
		}
		return res;
	}
New to GrepCode? Check out our FAQ X