Quick page lookup

×
Go!

★ Groovy

  • Documentation
    • Documentation Portal
    • Installing Groovy
    • Getting Started
    • User Guide
    • Testing Guide
    • Advanced Usage Guide
    • Developer Guide
    • Cookbook Examples
    • Groovy APIs
    • Groovy Development Kit
  • Community & Support
    • Welcome!
    • Groovy Sources
    • Mailing Lists
    • Bug Tracker
    • Wiki
    • Contributing
    • Related Projects
    • Modules
    • User Groups
  • IDE Support
    • Eclipse Plugin
    • IntelliJ IDEA Plugin
    • Other IDE plugins
  • Download

Creating XML using Groovy's StreamingMarkupBuilder

Here is an example of using StreamingMarkupBuilder to create a new XML file:

Note that StreamingMarkupBuilder.bind returns a Writable instance that may be used to stream the markup to a Writer, in addition to capturing the output in a String (as shown above).

We have used XMLUnit to compare the XML we created with our sample XML. To do this, make sure the sample XML is available, i.e. that the following class is added to your CLASSPATH:

XmlExamples.groovy

Here's another example illustrating how to produce mixed content:

You may also want to see Using MarkupBuilder for Agile XML creation.

 

Search

Results of your search request can come from various sources: the Groovy website itself, the JIRA issues, the API documentation, as well as a few other interesting Groovy-related blogs.

spacer
spacer  By  -  pages  -  views  - last modified 
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.