문제

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!

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top