Groovy系列:GPath
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Groovy系列:GPath相关的知识,希望对你有一定的参考价值。
//GPath can be used to easily query XML-based documents or even Object Graphs. //We start with looking at an XML GPath example. //Let's load the Grails Pocast RSS Feed first. //Like using XPath expressions, we can now navigate the tre //This accesses the first iem element of the RSS channel: //As in XPath, attributes are accessed with the @ syntax. //Let's see how many podcasts whe have done so far. //We can iterate over all items with this println item.title } //hier will ich die items nach Groovy Series filtern... //def groovySeries = feed.channel.item.findAll{ return (it.title.indexOf('Groovy Series')) ? true : false;} //wieso geht das nicht... println it.title geht //println "Found ${groovySeries.size()}" //playing with methods of GPathResult. NodeChild is an extension of GPathResult //to call the attributes method, we neet to macke sure that we are operating on a single Node, not a set try { { //above returns a NodeChildren object as it is a path expression for all enclosure tags of the first item tag! } //let's print all children of an item. //Beispiel mit GPathResult->find / findAll //evtl. xmlslurper dazu verwenden ein xml-doc zu veraendern??
以上是关于Groovy系列:GPath的主要内容,如果未能解决你的问题,请参考以下文章
groovy系列-groovy比起java,有哪些地方写起来更舒服
Gradle系列学习:初识Gradle之Groovy基础Gradle从入门到实战 - Groovy基础
Groovy使用 SwingBuilder 构建 Swing 窗口 ( 创建一个 Swing 构造器 | 配置 Swing 窗口的一系列属性 | 设置 Swing 窗口显示 )