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 6886243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:44:06+00:00 2026-05-27T05:44:06+00:00

I have a requirement where I am collecting system and some product specific information,

  • 0

I have a requirement where I am collecting system and some product specific information, so is there a way I can append the already existing xml’s content to the product tag, in my xml builder?

My test code to create a xml using groovy

import groovy.xml.MarkupBuilder
import org.custommonkey.xmlunit.*

def writer = new StringWriter()  
def builder = new groovy.xml.MarkupBuilder(writer) 

def xml=new XmlSlurper().parse("E:\\DomainMeta.xml")

builder.csm() { 
    system(osname:"linux", hostname:"panther")
    product()
    {
        //Here i'd like to add my xml content, starting with <DomainMeta>
    }

} 
println writer.toString() 

My xml, which has to be copied into another xml which i am building above

<DomainMeta>    //there can be more dynamic information inside DomainMeta tag
<Gateways>
<NodeRef name="N_116489" host="panther" httpPort="18,448" port="18,449" />
</Gateways>
<OptionGroup name="DomainOptions">
    <Option name="LicenseUsageDetailMinDays" value="90" ></Option>
</OptionGroup>
<OptionGroup name="NodeOptions">
    <Option name="LicenseUsageDetailMinDays" value="90" ></Option>
</OptionGroup>  
</DomainMeta>

Desired output

<csm>
  <system osname='linux' hostname='panther' />
  <product>
    <DomainMeta>
    <Gateways>
    <NodeRef name="N_116489" host="panther" httpPort="18,448" port="18,449" />
    </Gateways>
    <OptionGroup name="DomainOptions">
        <Option name="LicenseUsageDetailMinDays" value="90" ></Option>
    </OptionGroup>
    <OptionGroup name="NodeOptions">
        <Option name="LicenseUsageDetailMinDays" value="90" ></Option>
    </OptionGroup>
    </DomainMeta>
  </product>
</csm>

Update

One more Problem, The question that i asked is answered by tim_yates but i am facing another problem here, the xml data which comes as a dump is in a format given below, @tim: can you help?

&lt;DomainMeta&gt;
&lt;Gateways&gt;
&lt;NodeRef name="N_116489" host="panther" httpPort="18,448" port="18,449" /&gt;
&lt;/Gateways&gt;
&lt;OptionGroup name="DomainOptions"&gt;
    &lt;Option name="LicenseUsageDetailMinDays" value="90" &gt;&lt;/Option&gt;
&lt;/OptionGroup&gt;
&lt;OptionGroup name="NodeOptions"&gt;
    &lt;Option name="LicenseUsageDetailMinDays" value="90" &gt;&lt;/Option&gt;
&lt;/OptionGroup&gt;  
&lt;/DomainMeta&gt;
  • 1 1 Answer
  • 0 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-27T05:44:06+00:00Added an answer on May 27, 2026 at 5:44 am

    You can do it if you use StreamingMarkupBuilder like so:

    import groovy.xml.XmlUtil
    import groovy.xml.StreamingMarkupBuilder
    
    def xml = new XmlSlurper().parse("E:\\DomainMeta.xml")
    
    def out = new StreamingMarkupBuilder().bind { 
      csl {
        system(osname:"linux", hostname:"panther")
        product() {
           mkp.yield xml
        }
      }
    }
    
    println XmlUtil.serialize( out )
    

    Edit — Answer to secondary unrelated question

    If you have that in a variable called txt, you should be able to do:

    txt = txt.replace( '&lt;', '<' )
             .replace( '&gt;', '>' )
    

    Then, pass the txt to XmlSlurper.parseText()

    Though really, I’d say that this is an issue with the thing that is writing the source out so it is unusable as xml, but pretty on the web.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have requirement where some times I would like to load children as well
I have requirement of specifying web part connections in onet.xml. So when site is
I have requirement to get Facebook friends list with their images. How can I
My requirement is I have a Excel which contains some data. I would like
I have a requirement to implement some kind of dictionary object. Something like MyDict<K,V1,
I have some commercial equipment that I can connect to with a .Net library
Is there any PHP PDF library that can replace placeholder variables in an existing
I have a multi-step form in which some of the fields are collecting sensitive
I have a requirement to sort a collection of objects, They are shown on
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I

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.