I'm building a sitemap.xml by Spring MVC
@XmlRootElement(name = "urlset")
public class XmlUrlSet{
@XmlElements(@XmlElement(name = "url", type = XmlUrl.class))
private List<XmlUrl> sitemap = new ArrayList<XmlUrl>();
public void addUrl(XmlUrl xmlUrl) {
sitemap.add(xmlUrl);
}
public List<XmlUrl> getXmlUrls() {
return sitemap;
}
}
And it renders like this:
<urlset>
<url>
...
</url>
<url>
...
</url>
</urlset>
I just want to know how to add namespace for xml and xml version like Google's sitemap example?
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/foo.html</loc>
</url>
</urlset>