Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 683553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:43:11+00:00 2026-05-14T01:43:11+00:00

On the Groovy example page there is an example of how to use Groovy

  • 0

On the Groovy example page there is an example of how to use Groovy HTML builder with mixed content:

p [
        "This is some",
        b"mixed",
        "text. For more see the",
        ahref:'http://groovy.codehaus.org' ["Groovy"],
        "project"
  ]

This is however not working for me, I get an error message like:

expecting ']', found 'mixed' @ line 33, column 23. b"mixed", ^ 1 error 

The Groovy example page states that:

[Note: the syntax in some of these
examples is slightly out-dated. See
chapter 8 of GINA in the mean-time
until these examples are updated.]

My suspicion therefore is that the syntax of the HTML builder has changed, however I don’t have the book so I cannot check and I cannot seem to find any relevant example of this working online. Does anyone know how the syntax is supposed to be in Groovy 1.7 and have got this working?

  • 1 1 Answer
  • 10 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:43:12+00:00Added an answer on May 14, 2026 at 1:43 am

    I found a lot of the stuff in that example to be out dated. The syntax for mixed hrefs and the [] around the paragraph do not work for me.

    For mixed content, you need to use the special keyword ‘mkp.yield’. There is also an ‘mkp.yieldUnescaped’ if you don’t want escaping. There are some other functions you can do with mkp as well.

    This example does work and shows using mixed content:

    def builder = new groovy.xml.MarkupBuilder()
    builder.html {     
      head {         
        title"XML encoding with Groovy"     
      }     
      body {
        h1"XML encoding with Groovy"   
        p"this format can be used as an alternative markup to XML"      
    
        a(href:'http://groovy.codehaus.org', "Groovy")
    
        p {     
          mkp.yield "This is some"
          b"mixed"   
          mkp.yield " text. For more see the"
          a(href:'http://groovy.codehaus.org', "Groovy")
          mkp.yield "project"    
        }      
        p "some text"    
      } 
    }​
    

    Output:

    <html>
      <head>
        <title>XML encoding with Groovy</title>
      </head>
      <body>
        <h1>XML encoding with Groovy</h1>
        <p>this format can be used as an alternative markup to XML</p>
        <a href='http://groovy.codehaus.org'>Groovy</a>
        <p>This is some
          <b>mixed</b> text. For more see the
          <a href='http://groovy.codehaus.org'>Groovy</a>project
        </p>
        <p>some text</p>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following Groovy snippet to obtain the plain-text representation of an HTML-page
The example on this page only shows Groovy assertions without parentheses. assert a !=
Is there a way to use anonymous code blocks in Groovy? For example, I'm
In Groovy, there is a nice syntax for working with null values. For example,
The Groovy Process Management page mentions that: Because some native platforms only provide limited
I wanted to use groovy for a little ftp script and found this post
I'm dynamically running groovy scripts from scala. And there are some instances of some
I am using Groovy's handy MarkupBuilder to build an HTML page from various source
I started dabbling in groovy yesterday. There's an example on the groovy website that
I want use groovy findAll with my param to filtering closure filterClosure = {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.