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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:08:14+00:00 2026-05-28T00:08:14+00:00

It seems like this should be fairly obvious, but I can’t find anything on

  • 0

It seems like this should be fairly obvious, but I can’t find anything on how to simply (un)marshall XML elements which also have attributes using JAXB.

In other words, I understand how to use JAXB annotations to work with:

<element>foo</element>

And I understand how to use JAXB with:

<element attribute1="bar" attribute2="foo" />

But I can’t figure out how to approach something like:

<id_address href="/addresses/18">18></id_address_delivery>
<id_cart href="/carts/111">111</id_cart>
<id_currency href="/currencies/13">13></id_currency>

It feels like I should be able to do something like this (I’m using JAXB from Scala):

@XmlElement
@BeanProperty
var idAddress: XLink = _

@XmlElement
@BeanProperty
var idCart: XLink = _

@XmlElement
@BeanProperty
var idCurrency: XLink = _

And then define XLink as:

@XmlAccessorType(XmlAccessType.FIELD)
class XLink {

  @XmlAttribute
  @BeanProperty
  var href: String = _

  @Xml???
  @BeanProperty // ID is the container
  var id: Long = _
}

But obviously this doesn’t work, because id shouldn’t be a sub-element – it’s simply the value of the parent node.

This is such a common use case: what am I missing? For completeness, I’m using JAXB (MOXy) from Scala.

  • 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-28T00:08:15+00:00Added an answer on May 28, 2026 at 12:08 am

    I think you want @XmlValue.

    See here for more info.

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

Sidebar

Related Questions

This seems like it should be fairly straight-forward, but I can't see anything obvious.
This seems like it should be easy, but I can't quite find an explanation
This seems like it should be obvious but I can't figure it out. Suppose
This seems like it should be fairly simple, but for some reason I can't
Seems like this should be obvious, but how do I send arrow key presses
This seems like is should be fairly simple, but I am having trouble getting
This seems like its fairly simple, and should have been asked before, but everything
This seems like it should be fairly straightforward, but I'm having trouble coming up
Seems like this should be simple, but powershell is winning another battle with me.
Can this be done? It seems like this should be possible. In general, 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.