/ Published in: Groovy

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//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??
Comments
