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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:34:17+00:00 2026-06-08T12:34:17+00:00

I want to create from XML some objects, but when I’m trying I get

  • 0

I want to create from XML some objects, but when I’m trying I get this error:

[26/07/12 16:20:03:763 CEST] ERROR sitemap.SitemapXMLServlet:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.sitemaps.org/schemas/sitemap/0.9", local:"urlset"). Expected elements are <{}url>
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.sitemaps.org/schemas/sitemap/0.9", local:"urlset"). Expected elements are <{}url>

I can’t find the problem, and I don’t understand why it is getting wrong. This is what I tried:

XML File

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://LINK/shop/hoofdcategorie</loc>
        <lastmod>2012-07-26</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
    </url>
    <url>
        <loc>
            http://LINK/shop/hoofdcategorie/subcategorie
        </loc>
        <lastmod>2012-07-26</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
    </url>
</urlset>

Method what unmarshal the XML to an Object

public void getXML() {
    final JAXBContext context = JAXBContext.newInstance(SitemapXML.class);
    final Unmarshaller unmarshaller = context.createUnmarshaller();
    String xml = URLReader.readUrlHttpClient("http://LINK/shop/sitemap.xml");
    final UrlSet urlSet = (UrlSet) unmarshaller.unmarshal(new StreamSource(new StringReader(xml)));
}

UrlSet Class

@XmlRootElement(name = "urlset")
public class UrlSet {

    @XmlAttribute
    String xmlns;
    @XmlElement(name = "url")
    ArrayList<SitemapXML> sitemaps;


    public ArrayList<SitemapXML> getSitemaps() {
        return sitemaps;
    }

    public void setSitemaps(ArrayList<SitemapXML> sitemaps) {
        this.sitemaps = sitemaps;
    }

    @XmlAttribute
    public String getXmlns() {
        return xmlns;
    }

    public void setXmlns(String xmlns) {
        this.xmlns = xmlns;
    }
}

SitemapXML class what I mapping to url

@XmlRootElement(name = "url")
public class SitemapXML {

    String loc;
    Date lastmod;
    String changefreq;
    Double priority;

    public String getLoc() {
        return loc;
    }
    public void setLoc(String loc) {
        this.loc = loc;
    }
    public Date getLastmod() {
        return lastmod;
    }
    public void setLastmod(Date lastmod) {
        this.lastmod = lastmod;
    }
    public String getChangefreq() {
        return changefreq;
    }
    public void setChangefreq(String changefreq) {
        this.changefreq = changefreq;
    }
    public Double getPriority() {
        return priority;
    }
    public void setPriority(Double priority) {
        this.priority = priority;
    }
}
  • 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-08T12:34:24+00:00Added an answer on June 8, 2026 at 12:34 pm

    your xml uses a namespace, but your annotations don’t mention the namespaces. you can specify the namespace in the XmlRootElement annotation or add an XmlSchema annotation at the package level.

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

Sidebar

Related Questions

I want to create a Button otherthan creating it from xml layout.i want to
I use embedded SVG in XHTML and want to create animations from Javascript, but
Imagine that I want to create an array from another array like this: $array
I have some jpg files i want to create gif animated from them. i
I'm trying to create some xml , basically by reading rss feeds and adding
i want create a custom json data from the mssql 2008 results so that
I want to create a struct from data harvested by line from a file.
I want to create a view from the following two tables: Entry: entry_id entry_date
i want create multiple search where statement $where_search is a multiple condition from post
I have several UIImages and I want to create a video from them. 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.