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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:45:26+00:00 2026-06-02T05:45:26+00:00

I have list of XML files for the user to send the request. By

  • 0

I have list of XML files for the user to send the request. By runtime only i comes know what type of object JAXB is going to create. For example if user sends the request like

<books>
<name>Java</name>
</books>

Then i wants create a Book object. If the user sends the request like

<Customer>
<id>1</id>
</Customer> 

Then i wants to create a Customer object . But when i unmarshalling the XML using JAXB i need to specify the object type like

Person person= (Person) jaxbUnmarshaller.unmarshal(file); 

Is this anyway to create those objects dynamically?

Please help me.

  • 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-02T05:45:27+00:00Added an answer on June 2, 2026 at 5:45 am

    Without the explicit cast, with the code below object could hold an instance of Book or Person based on the content of the XML file.

    JAXBContext jc = JAXBContext.newInstance(Book.class, Person.class);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    Object object = unmarshaller.unmarshal(file) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some xml files that will be read-only that I need to access
I have a list of inactive_products in an XML file. I need to update
I have a list of xml elements that i need to search for specific
I have made a XML parser that list correctly in the UITableViewController. It passes
I have such xml: <bean id=conversionService class=org.springframework.context.support.ConversionServiceFactoryBean> <property name=converters> <list> <bean class=converters.AddressToStringConverter /> <bean
In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
I'm trying to access list data using SSRS 2008. I have created an XML
I have an excel list (excel 2003) where user enter translations for tokens. It
I have a content management system that I have designed which uses XML files
HI, I have a list of steps created by a user, in this list

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.