Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Here is a two line example of how to get a list of all the links to .xml files listed on a web page. The Neko parser is used to parse non-well formed html; it . It no longer ships as part of the standard Groovy distribution but can be downloaded and dropped into the lib directory of your Groovy distribution. You'll need to also add a copy of xercesImpl.jar to the groovy lib directory.

Code Block
def myDocument = new XmlParser( new org.cyberneko.html.parsers.SAXParser() ).parse("")
def links = myDocument.depthFirst().A['@href'].findAll{ it.endsWith(".xml") }