This Code…
import groovy.xml.*
StreamingMarkupBuilder smb = new StreamingMarkupBuilder()
smb.encoding = 'UTF-8'
def doc = smb.bind {
mkp.declareNamespace('':'http://www.sitemaps.org/schemas/sitemap/0.9')
urlset {
url {
loc(1)
lastmod('2019-09-21')
changefreq('daily')
priority('1')
one('b')
two('a')
three('c')
four('d')
five('e')
six('f')
seven('g')
}
}
}
println XmlUtil.serialize(doc)
Produces this xml …
<?xml version="1.0" encoding="UTF-8"?><urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>1</loc>
<lastmod
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">2019-09-21</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
<one xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">b</one>
<two>a</two>
<three>c</three>
<four xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">d</four>
<five>e</five>
<six>f</six>
<seven xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">g</seven>
</url>
</urlset>
But I was expecting …
<?xml version="1.0" encoding="UTF-8"?><urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>1</loc>
<lastmod>2019-09-21</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
<one>b</one>
<two>a</two>
<three>c</three>
<four>d</four>
<five>e</five>
<six>f</six>
<seven>g</seven>
</url>
</urlset>
Why am I getting all the extra xmlns attributes? Seems like every 3 nodes has
the namespace.
Nelson, Erick