Package groovy.util

Examples of groovy.util.XmlSlurper


                .endpointUri("http://localhost:51515/service")
                .build();

        String response = client.post(input);

        XmlSlurper slurper = new XmlSlurper(XMLReaderFactory.createXMLReader());
        return slurper.parseText(response).toString();
    }
View Full Code Here


    public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
        return newSlurper().parse(stream);
    }

    private XmlSlurper newSlurper() throws Exception {
        XmlSlurper slurper = new XmlSlurper(newSaxParser());
        slurper.setErrorHandler(getErrorHandler());
        slurper.setKeepWhitespace(isKeepWhitespace());
        return slurper;
    }
View Full Code Here

    private final XmlConverter xmlConverter = new XmlConverter();

    @Converter
    public GPathResult fromString(String input) throws ParserConfigurationException, SAXException, IOException {
        return new XmlSlurper().parseText(input);
    }
View Full Code Here

        return out.toString();
    }

    public static XmlSlurper createXmlSlurper() throws ParserConfigurationException, SAXException {
        SAXParserFactory factory = createParserFactory();
        return new XmlSlurper(factory.newSAXParser());
    }
View Full Code Here

    @SuppressWarnings("rawtypes")
    private void loadCorePluginsFromResources(Resource[] resources) throws IOException {

        LOG.debug("Attempting to load [" + resources.length + "] core plugins");
        try {
            XmlSlurper slurper = SpringIOUtils.createXmlSlurper();
            for (Resource resource : resources) {
                InputStream input = null;

                try {
                    input = resource.getInputStream();
                    final GPathResult result = slurper.parse(input);
                    GPathResult pluginClass = (GPathResult) result.getProperty("type");
                    if (pluginClass.size() == 1) {
                        final String pluginClassName = pluginClass.text();
                        if (StringUtils.hasText(pluginClassName)) {
                            loadCorePlugin(pluginClassName, resource, result);
View Full Code Here

    @SuppressWarnings("deprecation")
    public void testWriteSlurperResult() throws SAXException, ParserConfigurationException, IOException {
        String testXml = "<root><books><book isbn=\"45734957\">" +
                         "<title>Misery</title><author>Stephen King</author>" +
                         "</book></books></root>";
        GPathResult result = new XmlSlurper().parseText(testXml);

        StringWriter output = new StringWriter(testXml.length() + 20);
        GrailsUtil.writeSlurperResult(result, output);

        testXml = testXml.replaceAll("<root>", "<root xmlns='http://java.sun.com/xml/ns/j2ee'>");
View Full Code Here

        return false;
    }

    public static GPathResult asXml(String xml) {
        try {
            return (new XmlSlurper()).parseText(xml);
        } catch (Exception e) {
            throw new RuntimeException("invalid XML");
        }
    }
View Full Code Here

     * @throws IOException
     * @throws ParserConfigurationException
     */
    public static GPathResult xml(com.google.appengine.api.xmpp.Message message) throws IOException, SAXException, ParserConfigurationException {
        if (message.isXml()) {
            XmlSlurper slurper = new XmlSlurper();
            return slurper.parseText(message.getStanza());
        } else {
            throw new RuntimeException("You can't get the XML of this message as this is not an XML message.");
        }
    }
View Full Code Here

        return false;
    }

    public static GPathResult asXml(String xml) {
        try {
            return (new XmlSlurper()).parseText(xml);
        } catch (Exception e) {
            throw new RuntimeException("invalid XML");
        }
    }
View Full Code Here

     * @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 ) );
    }
View Full Code Here

TOP

Related Classes of groovy.util.XmlSlurper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.