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

  • Home
  • SEARCH
  • 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 9256965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:57+00:00 2026-06-18T12:05:57+00:00

I have the below class. When Marshalling, I would like to omit the tag

  • 0

I have the below class. When Marshalling, I would like to omit the tag “config”, is it possible?

@XmlRootElement(name = "config")
@XmlAccessorType(XmlAccessType.FIELD)
public static class Config {

        @XmlElement(name = "dry-run")
        protected Boolean dryRun;

        @XmlElementWrapper(name = "filters")
        @XmlElement(name = "filter")
        protected List<String> filters;

        public Boolean isDryRun() {
                return dryRun;
        }

        public void setDryRun(boolean dryRun) {
                this.dryRun = dryRun;
        }

        public List<String> getFilters() {
                return filters;
        }
}

Example:

Current output:

<Root>
  <config xmlns:wf="nspace">
    <dry-run>false</dry-run>
    <filters>
      <filter>
        myFilter
      </filter>
    </filters>
  </config>
</Root>

Desired output:

<Root>
    <dry-run>false</dry-run>
    <filters>
      <filter>
        myFilter
      </filter>
    </filters>
</Root>

UPDATE:

all I wanted to know is “can it be done ONLY with JAXB or not?”. Just check this question (not the answer), I didn’t get how he marshelled with only JAXB and no root element was written. It is precisely what I want.

  • 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-06-18T12:05:58+00:00Added an answer on June 18, 2026 at 12:05 pm

    So you want to marshal your object not to a single XML subtree, but to an XML fragment, i.e. a list of siblings without a parent. I believe there is no way to achieve this with Jaxb itself. But you can serialize to some intermediate form and process that. For example, you could create your own SAX ContentHandler and have that handler count depth and only delegate events at non-zero nesting depth.

    class NoRoot extends XMLFilterImpl {
    
      private int depth;
    
      @Override public void startDocument() throws SAXException
      {
        depth = 0;
      }
    
      @Override public void startElement(String uri, String localName,
                                         String qName, Attributes atts)
        throws SAXException
      {
        if (depth != 0) super.startElement(uri, localName, qName, atts);
        ++depth;
      }
    
      @Override public void endElement(String uri, String localName,
                                       String qName)
        throws SAXException
      {
        --depth;
        if (depth != 0) super.endElement(uri, localName, qName);
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have class like below class Person { public string Name{get;set;} public string Surname{get;set;}
I have a class like the one below: class Foo { private: std::map<std::string, Bar*>
Possible Duplicate: Hiding instance variables of a class I have below class AbstractTest public
I have a class like below: class Foo { public Foo(int x) { ...
I have an object like below class MyClass{ int a; double b; }; and
I have a class ExProperty something like below: class ExProperty { private int m_asimplevar;
I have a class (below). I have the field id for the class but
I have some code like below: class SingleValue { public: SingleValue() {} ~SingleValue() {}
I have the below public class Person { // Properties public string Name {
I have a django model as below class MySubject(models.Model): name=models.CharField(unique=True,max_length=50) description=models.TextField(blank=True) slug=models.SlugField(editable=False) class Meta:

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.