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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:50:42+00:00 2026-06-06T12:50:42+00:00

I’m working with a xml file that is generated and used in a .NET

  • 0

I’m working with a xml file that is generated and used in a .NET application.

I need to deserialize this file in Java and chose to use JAXB.

However, after trying to create the matching class I figured out one major difference.

When having a

@XmlRootElement
public class SomeClass{ 
    List<NestedClass> classes;
}

I get the following structure:

 <SomeClass>
        ...
        <NestedClasses>
        ...
        </NestedClasses>
        <NestedClasses>
        ...
        </NestedClasses>
    </SomeClass>

As oppesed to the required existing structure:

<SomeClass>
        ...
        <NestedClasses>
          <NestedClass>
          ...
          </NestedClass>
          <NestedClass>
          ...
          </NestedClass>
        </NestedClasses>
    </SomeClass>

Is there is a way to get my required structure without adding a class that will only contain the list of the nested class?

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

    You will need to have a class that wraps the collection. To get the desired mapping, you can use the @XmlElementWrapper annotation to specify that a grouping element should be used. Then you can use the @XmlElement annotation to specify the name of the element that represents the items in the collection:

    @XmlRootElement
    public class SomeClass{ 
        @XmlElementWrapper
        @XmlElement(name="NestedClass")
        List<NestedClass> classes;
    }
    

    For More Information

    • http://blog.bdoughan.com/2010/09/jaxb-collection-properties.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm parsing an XML file, the creators of it stuck in a bunch social
Thanks in advance for your help. I have a need within an application to

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.