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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:14:51+00:00 2026-05-26T18:14:51+00:00

He is my XML hosted on remote machine: <?xml version=1.0 encoding=UTF-8?> <store xmlns=http://mydomain.com/store/schemas> <!–

  • 0

He is my XML hosted on remote machine:

<?xml version="1.0" encoding="UTF-8"?>
<store xmlns="http://mydomain.com/store/schemas">
    <!-- My Book store-->
    <book location="vk 1">
        <title>Learning JAXB</title>
        <author>Joe Blogg</author>
    </book>
    <book location="vk 1">
        <title>Learning JAXB SE</title>
        <author>Joe Blogg</author>
    </book>
</store>

I have bind book as follows:

Book Binding:

@XmlRootElement(name = "book")
@XmlType(propOrder = { "title", "author"})
public class Book
{
 private String title;
 private String author;
 private String location;

 @XmlElement(name = "title")
 public String getTitle()
 {
  return title;
 }

 public void setTitle(String title)
 {
  this.title=title;
 }

 @XmlAttribute(name = "location")
 public String getLocation()
 {
  return location;
 }

 public void setLocation(String location)
 {
  this.location = location;
 }

 @XmlElement(name = "author")
 public String getAuthor()
 {
  return author;
 }

 public void setAuthor(String author)
 {
  this.author = author;
 }
}

Store Binding:

@XmlRootElement(name = "store", namespace = "http://mydomain.com/store/schemas")
public class Store
{
 private List<Book> books;

  @XmlElement(name="book")
  public List<Book> getBooks()
  {
    return books;
  }

  public void setBooks(List<Book> books)
  {
    this.books= books;
  }
}

I am unmarshalling the XML file as fAollows:

  JAXBContext context = JAXBContext.newInstance(Store.class);
  Unmarshaller unmarshaller = context.createUnmarshaller();
  URL url = new URL("http://mydomain/files/store.xml");
  Store s= (Store) unmarshaller.unmarshal(url);
  System.out.println(s.getBooks());// Prints null

When I call getBooks() we get null value. Can anyone spot what I am doing wrong here?!

  • 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-26T18:14:51+00:00Added an answer on May 26, 2026 at 6:14 pm

    The answer provided by skaffman is incorrect. You can specify the namespace at the package level via @XmlSchema or at the class level using @XmlType and have it be used to qualify the fields/properties:

    For More Information

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

Sidebar

Related Questions

I have the following XML: <?xml version=1.0?> <?xml-stylesheet type=text/xsl href=http://www.test.com/AuditTrail.xsl?> and XSL: <?xml version=1.0
im currently parsing an xml file that is hosted on another PC via hosting
I have myself a self-hosted WCF server setup, which serves a clientaccesspolicy.xml and an
I'm trying to connect to a remote database (hosted on Netfirms www.netfirms.ca if anyone
Have a WCF service (hosted in IIS 6.0) that takes an XML feed from
Remote clients can't access Delphi WebService hosted in IIS 7.5 Delphi WS clients are
I want to download a hosted XML document into my app's bundled SQLite database,
After changing domain name where flash application being hosted I should change crossdomain.xml file.
There is a self hosted WCF REST service, need to send an xml post
I have an xml file that is emailed to an email address hosted on

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.