protected GPathResult method(XmlSlurper slurper) throws Exception { return slurper.parse(source); } };
/** * @return A new Xml slurper * @throws ParserConfigurationException If there is a parser error * @throws SAXException If there is an error with SAXO */ public static XmlSlurper createXmlSlurper() throws ParserConfigurationException, SAXException { return new XmlSlurper(newSAXParser()); }
protected GPathResult method(XmlSlurper slurper) throws Exception { return slurper.parseText(text); } };
final XmlSlurper slurper; if (compatibilityMode == XML) { slurper = new XmlSlurper(config.isValidating(), config.isNamespaceAware(), config.isAllowDocTypeDeclaration()); } else { XMLReader p = new org.ccil.cowan.tagsoup.Parser(); slurper = new XmlSlurper(p); slurper.setFeature(feature.getKey(), feature.getValue()); slurper.setProperty(feature.getKey(), feature.getValue());
public static String getLauncherIcon(File manifestFile) throws SAXException, ParserConfigurationException, IOException { GPathResult manifestXml = new XmlSlurper().parse(manifestFile); GPathResult applicationNode = (GPathResult) manifestXml.getProperty("application"); return String.valueOf(applicationNode.getProperty("@android:icon")); } }
/** * Standard parser for xml responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static GPathResult xml(final ChainedHttpConfig config, final FromServer fromServer) { try { final XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver(catalogResolver); xml.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return xml.parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException | ParserConfigurationException ex) { throw new RuntimeException(ex); } }
public XmlSlurper(String name, String input) throws IOException, SAXException, ParserConfigurationException { this.name = name; this.input = new groovy.util.XmlSlurper().parseText(input); }
/** * Default parser used to decode an XML response. * @see ContentType#XML * @see XmlSlurper#parse(Reader) * @param resp HTTP response from which to parse content * @return the {@link GPathResult} from calling {@link XmlSlurper#parse(Reader)} * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public GPathResult parseXML( HttpResponse resp ) throws IOException, SAXException, ParserConfigurationException { XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver( catalogResolver ); return xml.parse( parseText( resp ) ); }
private XmlSlurper newSlurper() throws Exception { XmlSlurper slurper = new XmlSlurper(newSaxParser()); slurper.setErrorHandler(getErrorHandler()); slurper.setKeepWhitespace(isKeepWhitespace()); return slurper; }
private XmlSlurper slurper() throws Exception { XmlSlurper slurper = new XmlSlurper(saxParser()); slurper.setErrorHandler(new SimpleSaxErrorHandler(LOG)); return slurper; }
public void endElement(final String namespaceURI, final String localName, final String qName) throws SAXException { addCdata(); Node oldCurrentNode = stack.pop(); if (oldCurrentNode != null) { currentNode = oldCurrentNode; } }
/** * Parse the content of the specified input source into a GPathResult object * * @param input the InputSource to parse * @return An object which supports GPath expressions * @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 GPathResult parse(final InputSource input) throws IOException, SAXException { reader.setContentHandler(this); reader.parse(input); return getDocument(); }
/** * Parse an HTML document by passing it through the NekoHTML parser. * @see ContentType#HTML * @see org.cyberneko.html.parsers.SAXParser * @see XmlSlurper#parse(Reader) * @param resp HTTP response from which to parse content * @return the {@link GPathResult} from calling {@link XmlSlurper#parse(Reader)} * @throws IOException * @throws SAXException */ public GPathResult parseHTML( HttpResponse resp ) throws IOException, SAXException { XMLReader p = new org.cyberneko.html.parsers.SAXParser(); p.setEntityResolver( catalogResolver ); return new XmlSlurper( p ).parse( parseText( resp ) ); }
/** * Standard parser for xml responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static GPathResult xml(final ChainedHttpConfig config, final FromServer fromServer) { try { final XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver(catalogResolver); xml.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return xml.parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException | ParserConfigurationException ex) { throw new TransportingException(ex); } }
public static GPathResult asXml(String xml) { try { return (new XmlSlurper()).parseText(xml); } catch (Exception e) { throw new RuntimeException("invalid XML", e); } }
/** * Default parser used to decode an XML response. * @see ContentType#XML * @see XmlSlurper#parse(Reader) * @param resp HTTP response from which to parse content * @return the {@link GPathResult} from calling {@link XmlSlurper#parse(Reader)} * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public GPathResult parseXML( HttpResponse resp ) throws IOException, SAXException, ParserConfigurationException { XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver( catalogResolver ); return xml.parse( parseText( resp ) ); }
final XmlSlurper slurper; if (compatibilityMode == XML) { slurper = new XmlSlurper(config.isValidating(), config.isNamespaceAware(), config.isAllowDocTypeDeclaration()); } else { XMLReader p = new org.ccil.cowan.tagsoup.Parser(); slurper = new XmlSlurper(p); slurper.setFeature(feature.getKey(), feature.getValue()); slurper.setProperty(feature.getKey(), feature.getValue());
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes atts) throws SAXException { addCdata(); final Map<String, String> attributes = new NamespaceAwareHashMap(); final Map<String, String> attributeNamespaces = new HashMap<String, String>(); for (int i = atts.getLength() - 1; i != -1; i--) { if (atts.getURI(i).length() == 0) { attributes.put(atts.getQName(i), atts.getValue(i)); } else { String key = new QName(atts.getURI(i), atts.getLocalName(i)).toString(); attributes.put(key, atts.getValue(i)); attributeNamespaces.put(key, atts.getURI(i)); } } final Node newElement; if (namespaceURI.length() == 0) { newElement = new Node(currentNode, qName, attributes, attributeNamespaces, namespaceURI); } else { newElement = new Node(currentNode, localName, attributes, attributeNamespaces, namespaceURI); } if (currentNode != null) { currentNode.addChild(newElement); } stack.push(currentNode); currentNode = newElement; }
/** * Parse the content of the specified input source into a GPathResult object * * @param input * @return An object which supports GPath expressions * @throws IOException * @throws SAXException */ public GPathResult parse(final InputSource input) throws IOException, SAXException { this.reader.setContentHandler(this); this.reader.parse(input); return getDocument(); }
protected GPathResult method(XmlSlurper slurper) throws Exception { return slurper.parse(reader); } };