HI All,  I've been using dom4j for a while but never really dived into
namespaces.  I'm trying to create a sitemap.xml as described here ::
http://www.sitemaps.org/protocol.html

They ask for a namespace on the document and the sample structure
looks like this:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"; >
  <url>
    <loc>...

I am unable to create that structure exactly.  If I do this:

Element root = DocumentHelper.createElement("urlset");
root.addNamespace("sitemap", "http://www.sitemaps.org/schemas/sitemap/0.9";);
Document doc = DocumentHelper.createDocument(root);

I end up with a structure like :
<urlset xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9";>
  <url>
    <loc>...

With the "sitemap" appended to "xmlns".  But if I leave that prefix
empty (javadocs warns against this. I know) like this:

Element root = DocumentHelper.createElement("urlset");
root.addNamespace("", "http://www.sitemaps.org/schemas/sitemap/0.9";);
Document doc = DocumentHelper.createDocument(root);

I end up with a structure like :
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";>
  <url xmlns="">
    <loc>...

With a weird empty "xmlns" attribute for the direct child elements of
<urlset>. I apologize in advance for what must be a newbie error but
if anyone has a solution I'd appreciate it.

Thanks,
Galen

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to