/** * @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()); }
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);
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);
def manifest = new XmlSlurper().parse(file("AndroidManifest.xml")) // returns "com.exmaple.your.app" manifest.@package.text()
def alum = new XmlSlurper().parseText(xmlResponse) alum.connections.person.each { conName -> def myMap = [:] conName.children().each { child -> myMap[child.name()] = child.text() } }
def alert = com.eviware.soapui.support.UISupport; def req = new XmlSlurper().parseText(mockRequest.requestContent) if(req=='CI'){ alert.showInfoMessage("111111 ! "+req); return "CityResponse" }else if(req=='ST'){ alert.showInfoMessage("2222222 ! "+req); return "StateResponse" }else{ alert.showInfoMessage("333333 ! "+req); return "CountryResponse" }
File pluginManifestFile = file(project.absolutePath + "/src/main/AndroidManifest.xml") if(pluginManifestFile.exists()){ String manifestContents = pluginManifestFile.text def pluginManifestXml = new XmlSlurper().parseText(manifestContents) String packageName = pluginManifestXml.@package.toString() println 'Package name of the library is: ' + packageName }
def parser = new XmlSlurper() parser.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false ) parser.setFeature( "http://xml.org/sax/features/namespaces", false ) parser.parseText( xml )
def writer = new StringWriter() def xml = new MarkupBuilder(writer) xml.records() { car(name:'HSV Maloo', make:'Holden', year:2006) { country('Australia') record(type:'speed', 'Production Pickup Truck with speed of 271kph') } } def records = new XmlSlurper().parseText(writer.toString())
def manifestXml = new XmlSlurper().parse(Manifest) manifestXml."uses-permission".each { p -> println p."@android:name" }
def records = new XmlSlurper().parseText(YOURHTMLSTRING) def allNodes = records.depthFirst().collect{ it } def list = [] allNodes.each { it.text().tokenize().each { list << it } }
def queryxml = new XmlSlurper().parseText( xml ) List<MyQuery> query = queryxml.query.findAll { node -> // Filter the nodes node.@operation.text() == 'create' }.collect { node -> // For each matching node, create a class new MyQuery( node.text().trim() ) } println query
def xml = new XmlSlurper().parseText("""<parent><child1><subchild1></subchild1></child1><child2><subchild2></subchild2></child2></parent>""") def buildXPathFromParents = { if (it.parent().is(it)) {"/" + it.name() } // If we are our own parent, then we are the highest node, so return our name. else {call(it.parent())+ "/" + it.name() } // if we have a parent node, append our path to its path. } def endNodes = xml.depthFirst().findAll{!it.childNodes()} // find all nodes which dont have any children def xPaths = endNodes.collect{buildXPathFromParents(it)} print xPaths
private XmlSlurper newXmlSlurper() { try { return new XmlSlurper(); } catch (ParserConfigurationException | SAXException e) { throw new IllegalArgumentException(e); } }
public XmlSlurper(String name, String input) throws IOException, SAXException, ParserConfigurationException { this.name = name; this.input = new groovy.util.XmlSlurper().parseText(input); }
public static GPathResult asXml(String xml) { try { return (new XmlSlurper()).parseText(xml); } catch (Exception e) { throw new RuntimeException("invalid XML", e); } }
import groovy.xml.XmlUtil import groovy.xml.StreamingMarkupBuilder def xml = new XmlSlurper().parse("E:\\DomainMeta.xml") def out = new StreamingMarkupBuilder().bind { csl { system(osname:"linux", hostname:"panther") product() { mkp.yield xml } } } println XmlUtil.serialize( out )
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")); } }
private XmlSlurper slurper() throws Exception { XmlSlurper slurper = new XmlSlurper(saxParser()); slurper.setErrorHandler(new SimpleSaxErrorHandler(LOG)); return slurper; }
private XmlSlurper newSlurper() throws Exception { XmlSlurper slurper = new XmlSlurper(newSaxParser()); slurper.setErrorHandler(getErrorHandler()); slurper.setKeepWhitespace(isKeepWhitespace()); return slurper; }