/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root ; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringWriter writer = new StringWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
@Override public void setUp() throws Exception { super.setUp(); InputStream is = getContext().getAssets().open("test.xml"); XmlParser parser = new XmlParser(getContext()); parser.parse(is); ... } @MediumTest public void testSomething() throws Exception { // test some data your parser extracted from the xml file ... }
/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
/** * A helper method to parse the given text as XML. * * @param text the XML text to parse * @return the root node of the parsed tree of Nodes * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @throws IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public Node parseText(String text) throws IOException, SAXException { return parse(new StringReader(text)); }
public class ExampleITest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); InputStream is = getContext().getAssets().open("test.xml"); XmlParser parser = new XmlParser(getContext()); parser.parse(is); ... } @MediumTest public void testSomething() throws Exception { // test some data your parser extracted from the xml file ... } }
@Override public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { return parser().parse(stream); }
@Override public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { return newParser().parse(stream); }
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root = null; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringWriter writer = new StringWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root = null; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringWriter writer = new StringWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root ; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringWriter writer = new StringWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root = null; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringWriter writer = new StringWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
private void taskdef(Map<String, String> args) { Set<String> argNames = args.keySet(); if (argNames.equals(ImmutableSet.of("name", "classname"))) { try { String name = args.get("name"); String className = args.get("classname"); addTaskDefinition(name, className); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } } else if (argNames.equals(Collections.singleton("resource"))) { InputStream instr = antlibClassLoader.getResourceAsStream(args.get("resource")); try { Node xml = new XmlParser().parse(instr); for (Object taskdefObject : (NodeList) xml.get("taskdef")) { Node taskdef = (Node) taskdefObject; String name = (String) taskdef.get("@name"); String className = (String) taskdef.get("@classname"); addTaskDefinition(name, className); } } catch (Exception ex) { throw UncheckedException.throwAsUncheckedException(ex); } finally { IOUtils.closeQuietly(instr); } } else { throw new RuntimeException("Unsupported parameters for taskdef(): " + args); } }
Node xml; try { xml = new XmlParser().parse(getLookupUrlFor(address)); } catch (Exception e) { LAST_FAILURE_UTC = System.currentTimeMillis();
Node xml; try { xml = new XmlParser().parse(getLookupUrlFor(address)); } catch (Exception e) { if (log.isDebugEnabled())
public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { Node root ; try { root = xmlParser.parse(reader); } catch (SAXException e) { throw new RuntimeException("Parsing XML source failed.", e); } if (root == null) { throw new IOException("Parsing XML source failed: root node is null."); } StringBuilderWriter writer = new StringBuilderWriter(1024); writer.write("/* Generated by XmlTemplateEngine */\n"); new GspPrinter(new PrintWriter(writer), indentation).print(root); Script script; try { script = groovyShell.parse(writer.toString(), "XmlTemplateScript" + counter++ + ".groovy"); } catch (Exception e) { throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage()); } return new XmlTemplate(script); }
public void oncreate(){ // Do something or mostly the basic code // Call the class to initate the connection and get the data FetchList fl = new FetchList(); fl.execute(); } //Always better to use async task for these purposes public class FetchList extends asyncTask<Void,Void,Byte>{ doinbackground{ // this was explained in first step Response res = new Response("url"); String response = res.getResponse(); XmlParser xml = new XmlParser(response); ArrayList<item> itemList = xml.getItemList(); xml.parse(); } }