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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:04:26+00:00 2026-06-09T09:04:26+00:00

I was wondering something about xml parsing in java. While I’m reading xml file

  • 0

I was wondering something about xml parsing in java. While I’m reading xml file in java, is it possible to create simultaneously objects of xml tags. Let me give an example.
This is my xml file. I read it. I can get firstname lastname etc… While reading it, i want to create an employee object with firtname and lastname values. I know that I can create an employee class and when I’m reading data I can assign values to this class but I don’t want to do it in this way. Does java provide any easier way to create an employee object. I hope it is clear what I mean.

<company>
<employee>
    <firstname>Tom</firstname>
    <lastname>Cruise</lastname>
</employee>
<employee>
    <firstname>Paul</firstname>
    <lastname>Enderson</lastname>
</employee>
<employee>
    <firstname>George</firstname>
    <lastname>Bush</lastname>
</employee>

  • 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-09T09:04:28+00:00Added an answer on June 9, 2026 at 9:04 am

    You could try and use XStream. It should allow you to create objects in a very simple manner (from their 2-minute tutorial), you could do something like so:
    Employee emp = (Employee)xstream.fromXML(xml);

    However, note that your Employee node is nested within the Company node, so you might need to do some extra work. As is, your XML would at most be rendered in a class named Company which has a list of Employees.

    Note however, you will need to have the classes which match the XML available before hand.

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

Sidebar

Related Questions

I'm wondering if I'm missing something about Java Beans. I like my objects to
Something I have been wondering about properties for a while. When you are using
I've been using QT for a while now and I've been wondering about something
I was just wondering about something. I have a frame that loads pages and
I'm just wondering what are you thinking about DIV-tag inside FORM-tag? I need something
I was wondering if something was possible to do in CSS. Basically i want
I'm wondering if there is something like Hotswap/HotDelpoy/JRebel (known from Java World) in .NET
I'm programming in objective-C for several iPod devices and I was wondering about something.
I am wondering how it's possible to create bottom bar buttons in android, I
Out of curiosity I'm wondering if I can do something about this because I'm

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.