Frage

I'm generating sitemaps and their index with JDOM2.

what I'd like to obtain is this:

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>http://

so I added an attribute to the root element titled "xmlns". Running the code I receive this error:

The name "xmlns" is not legal for JDOM/XML attributes: An Attribute name may not be "xmlns"; use the Namespace class to manage namespaces.

How can I obtain what I need without changing the above structure? thanks!

War es hilfreich?

Lösung

You need to use namespaces, not attributes:

Element root = new Element("sitemapindex", "http://www.sitemaps.org/schemas/sitemap/0.9");

Read up on namespaces....: http://www.w3schools.com/xml/xml_namespaces.asp

Rolf

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top